Odd NSAlert behavior with Script Menu

Just yesterday I was trying to write a script so that I could open a custom alert dialog and enter some text into a combobox (adapting some code I found elsewhere). It works fine when run from the Script Editor, but when I run it from the Script Menu, any text I try to enter goes to whatever app is behind the alert, not into the combo box itself (e.g., if the alert is over a Script Editor window, the text gets typed into SE at the current insertion point). Here’s the code I’m using:

use AppleScript version "2.4" -- Yosemite 10.10 or later
use framework "Cocoa"
use scripting additions

property ca : current application
property NSAlert : class "NSAlert"
property NSComboBox : class "NSComboBox"
property NSArray : class "NSArray"

set alert to NSAlert's alloc()'s init
alert's addButtonWithTitle:"Select"
alert's addButtonWithTitle:"Cancel"
set alert's informativeText to ""
set alert's messageText to "Enter text"
set alert's |window|'s floatingPanel to true

set cframe to ca's NSMakeRect(0, 0, 215, 26)
set combobox to NSComboBox's alloc()'s initWithFrame:cframe
set display_list to NSArray's arrayWithArray:{"alpha", "beta", "gamma"}
combobox's addItemsWithObjectValues:display_list
combobox's setCompletes:true
combobox's setHasVerticalScroller:true

-- place the combo box on the alert panel as an accessory
alert's setAccessoryView:combobox
set modalResponse to alert's runModal()

I’m sure this has something to do with the fact that NSAlert is app-modal, and the ‘app’ in this question is the background process that runs the Script Menu, but I can’t see how to get around it. Is there a trick I’m missing, or is this a lost cause? I mean, I know this is possible — ‘display dialog’ is a modal alert that takes text, even when run from the Script Menu — but I don’t know how ‘display dialog’ is constructed to achieve that.

I’ve tested with the standard NSSave and NSOpen alerts, and see the same problem. I suppose I could rewrite this as an applet and run that (which I’m sure would solve the problem), but still… Any insights?

P.s. Catalina, with a 2019 MacBook Pro, if that makes any difference…

That’s weird. Other controls work fine in my Dialog Toolkit scripts, so it seems specific to the combobox, presumably something to do with how it’s assigning its field editor.

FWIW, your code works fine fromFastScripts.

I just tested it with a text field and got the same problem. Buttons and popups seem to work fine, but text passes through it like water. You may be right about the field editor, But I don’t see any way to test that (since the durned thing is modal).

I’ve never used FastScripts or your Dialog Toolkit, and to say. I should look into that.

At any rate, I’ve solved the short-term problem by converting the script to an app and setting its LSUIElement to true, which (surprisingly) seems to work. But I’m still curious about why that fall-through occurs.

Model: MacBookPro15,1
Browser: Safari 605.1.15
Operating System: macOS 10.14

I’m not seeing any problem with text fields in Dialog Toolkit Plus, so you might compare your code with its.

(And FastScripts is a must.)