Why isn't entry box open when gettext is invoked?

When I set up a gettext gadget I would expect that the entry box would already be open ready for me to type in. But in fact I have to click to open the text entry field before I can type in it. A minor annoyance, but an annoyance.

This used to work in previous versions of OS X, but Apple made a change and it doesn’t work any more. I cannot find any Apple documentation that indicates why this has changed, or how to control this behavior.

You might want to look at this topic: An experimental GetTextSheet procedure

I have installed gettextsheet as a custom statement, and it works the way we want it.

Thanks, Bruce (and Gary and Jim), I’ll try it out tomorrow.

I wonder if gettextsheet could be rewritten so it is a separate dialog box to substitute for the code for gettext, so that it works properly.

For us this is a major annoyance. Jim, I would be happy to personally email Tim Cook and complain. I just need to know how to describe the problem in terms he or someone he bumps it to will understand.

Not that it will do any good, but it’s worth a try. I saw Gary’s workaround but we shouldn’t have to be constructing complicated fixes for problems Apple creates for no apparent reason.


PS For us this means continuing to use Pan 6 for this particular database until it ceases working. Sigh.

Probably of no help to Jim but I found this in the Apple Text Editing documentation. I assume Jim is fully aware of this and that it does not answer the problem at hand - but just in case…

Setting Focus and Selection Programmatically

Usually the user clicks a view object in a window to set the focus, or first responder status, so that subsequent keyboard events go to that object initially. Likewise, the user usually creates a selection by dragging the mouse in a view. However, you can set both the focus and the selection programmatically.

For example, if you have a window that contains a text view, and you want that text view to become the first responder with the insertion point located at the beginning of any text currently in the text view, you need a reference to the window and the text view. If those references are theWindow and theTextView , respectively, you can use the following code to set the focus and the insertion point, which is simply a zero-length selection range:

[theWindow makeFirstResponder: theTextView];
[theTextView setSelectedRange: NSMakeRange(0,0)];

Yes, fully aware, and Panorama uses this API in several places. It’s not helpful in this case because Panorama isn’t responsible for the NSTextView object inside the dialog – it is set up by the NSAlert API, and Panorama can’t get inside that API and affect what is going on.

I see you are not an Apple developer, if so, you wouldn’t be saying that!! :slight_smile:

Feel free to email Tim Cook about this, I’m sure he will get right on it (wink wink). Actually what he (or any Apple employee) will say is “file a radar”, which has already been done. (Radar is Apple’s bug reporting system, it’s like the Bitbucket system Panorama X uses but it’s not public, it’s basically a black hole into which bug reports disappear.)

I would think implementing the mehod Gary came up with (thanks again) would be easier than continuing to use Panorama 6 for this, especially since I know you are using Panorama X extensively elsewhere.

If there’s one thing that’s certain, it’s that I’m not an Apple developer.

I tried to figure out how to integrate Gary’s Gettextsheet procedure into my code but can’t get it to work. So back to pleading for assistance, as usual. Thank goodness for the patience of this forum’s gurus!

Here’s the code:

window “PriceSource.2”
_ _
local theSearchTerm, thisWindow
growlmessage "The source window is: "+thisWindow


_ GetText “Enter the complete item number:”, theSearchTerm_
_ if theSearchTerm=""_
_ AlertNoYes “You did not enter a search term. Would you like to stop searching?”_
_ Repeatloopif info(“DialogTrigger”) contains “No” _
_ endif_
_ _
_ Select ItemNum MATCH theSearchTerm_
_ _
_ if ItemNum NOTMATCH theSearchTerm_
_ AlertYesNo “I didn’t find any items matching your term; try again?”_
_ Repeatloopif info(“DialogTrigger”) contains “Yes”_
_ endif_
_ _
_ /* everything’s okay–go ahead and build the array */_
_ _
_ local theExportText,theQuantity_
_ GetText “How many?:”, theQuantity_
_ arrayselectedbuild theExportText, ¶ ,"",ItemNum+¬+str(Available)+ ¬ +theQuantity_
_ OpenFile “ResourceStorage”_
_ Window “ResourceStorage”_
_ OpenFile “+@theExportText”_
_ LastRecord_
_ Field ItemNum_
_ window (thisWindow)_

while forever

And a brief explanation:

Most orders to our business come via the website but we still get the occasional faxed, emailed, or phoned-in order. Those have to be put gussied up so the order can be picked and processed. Years ago I created a couple of databases which I called QuickOrder. The only info we need to enter are the item numbers and quantities ordered. All other needed data can then be quickly added using lookups.

The code above is actually one of three similar data entry choices the user has. He/she can enter the entire item number, or if there are a number items with the same prefix (“11-” for example) the user can store the prefix in a variable and then only needs to enter the color number. (So the user enters “11-” at the beginning, for example, and then can enter “401” which the procedure transforms into the correct item, “11-401”.) Finally there is a third option for another large group of items which begin with DB. I’ll spare you the details of that one.

Anyway, they all happily used gettext and saved us a lot of keying time. Until Apple broke the text entry bit.

So if Gary or someone can gently explain how to incorporate his fancy gettext into my simple code above, I should then be able to adapt it for the variations.

Merci mille fois, vielen Dank, muchas gracias, tack so mycket, and endless thanks.



So, Barry, first you create a new procedure named .gettextsheet and copy this code into it:

global __theText__,__thePrompt__
local targetFormName
define targetFormName,"•|•|•"
If dbinfo("forms","") contains targetFormName
    setformoptions "",targetFormName,"DELETE",""
    //removes old form if for some reason it was not previously deleted
makenewform targetFormName
setformoptions "",targetFormName,
            //had to run form options before opening form to take effect
    rundialog {Form=}+targetFormName+{ Height=150 Width=450 sheet=true CancelButton=Stop}
    stoploopif info("trigger") = "Dialog.Close"
    if info("trigger") contains "Dialog.Initialize"
        newformobject  "RectangleShapeObject",
            "rectangle",rectanglesize(0, 0, 267, 679),
            "Opacity","0 %"
            //this object keeps the Text Editor from closing if the background is clicked
        newformobject "ImageDisplayObject",
            "rectangle",rectanglesize(12, 23, 62, 62),
            "Procedure","if info({modifiers}) contains {option} closewindow endif",
        newformobject "PushButtonObject",
            "rectangle",rectanglesize(82, 221, 26, 80),
            "TextSize","13 px",
            "Procedure","resume {}",
            "$PushButtonStyle","Push Button",
        newformobject "PushButtonObject",
            "rectangle",rectanglesize(82, 319, 26, 88),
            "TextSize","13 px",
            "Procedure","resume {}",
        newformobject "TextEditorObject",
            "rectangle",rectanglesize(44, 101, 22, 308),
            "$TextEditorEmptyPrompt","Enter text...",
            "Procedure","resume {}",
            "TextSize","13 px",
            //named Text Editor "Button.Ok" to return properly close the dialog
        newformobject "TextDisplayObject",
            "rectangle",rectanglesize(14, 99, 22, 308),
            "TextSize","13 px",
        SuperObject "Button.Ok","Open"
        settrigger ""
setformoptions "",targetFormName,"DELETE",""
If dlgResult≠"Cancel"
    setparameter 2, __theText__
    settrigger "Stop"
undefine __theText__, __thePrompt__
If info("trigger")="Stop"

Now in your code simply substitute “call .gettextsheet,” in place of GetText leaving the parameters as they are in your code. That (hopefully) should do it.

Note: I initially forgot to add the comma after the call statement before your existing parameters.:confused:

Progress! Once I figured out that I was putting your procedure in the wrong database, I got a dialog window. However as soon as I entered an item number and pressed enter, I was told:

Cannot set parameter value because parameter 2 is not a field or variable.

Next step?

thanks thanks


I don’t know where that is coming from. Try this simple test in a test procedure and see if it works:

call  .gettextsheet,"Enter Something…",theText 
message theText

Also gives an error message. Don’t know if you’ll get the screen shot; if not it says:

cannot set parameter 2 value

and the word “setparameter” is highlighted close to the end of your code here:


setformoptions “”,targetFormName,“DELETE”,""

If dlgResult≠"Cancel"

setparameter 2, theText


settrigger “Stop”


So something’s odd but I don’t know what. I’ll try it again in a brand new database…


I wonder if any invisible characters are messing up the code as it was copied from email…


–Looked at the copied-from-email-procedure in BBEdit this morning and don’t see any evil invisibles. I’m stymied.

I just put a sample database with the gettextsheet procedure along with a test procedure that all works as advertised at my end. You can down load it here and give it a test.

404 error for the download link

Ok, I just moved it to a different spot on the server so you can try this: http://www.unseensoft.com/GetTextSheetExample.zip

GoDaddy recently convinced me to move my site from an old Windows server to a more modern Linux server and I’m having some growing pains.

Yours works perfectly. Will now test it in my mess.


Would be interested to know what the problem turns out to be and why you were getting those errors.

I uploaded a file with a custom statement to the database exchange. It is 99% based on Gary’s procedure for using the alertsheet for user input. I use it instead of Gettext. The input box is active when the alertsheet opens. The file has instructions for how to install a custom statement in case a user is new to that process and it has instructions to use the custom statement. The first time you use it in a database, it will add a form that is needed (ALERTSHEETINPUT). The filename in database exchange is alertsheetinputcustomstatement.