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


#1

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.


#2

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.


#3

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.


#4

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


#5

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.


#6

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.

Thanks,
bk

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


#7

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)];


#8

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.


#9

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
theSearchTerm=""
thisWindow=info(“windowname”)
growlmessage "The source window is: "+thisWindow

Loop

_ 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” _
_ STOP_
_ 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”_
_ STOP_
_ 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.

Vote!

bk


#10

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

global __theText__,__thePrompt__
__theText__=catcherror("",parameter(2))
__thePrompt__=parameter(1)
local targetFormName
define targetFormName,"•|•|•"
If dbinfo("forms","") contains targetFormName
    setformoptions "",targetFormName,"DELETE",""
    //removes old form if for some reason it was not previously deleted
endif
makenewform targetFormName
setformoptions "",targetFormName,
            "ALTERNATINGBACKGROUNDCOLORS",-1,
            "BACKGROUNDCOLOR",htmlrgb("EDEDED")
            //had to run form options before opening form to take effect
loop
    rundialog {Form=}+targetFormName+{ Height=150 Width=450 sheet=true CancelButton=Stop}
    stoploopif info("trigger") = "Dialog.Close"
    if info("trigger") contains "Dialog.Initialize"
        makeFormObjectsFromBluePrint:
        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),
            "color",htmlrgb("000000"),
            "Procedure","if info({modifiers}) contains {option} closewindow endif",
            "Formula",""""+bundleresourcepath("")+"/AppIcon.icns""",
            "$ImageDisplayAlignment","Proportional"
        newformobject "PushButtonObject",
            "rectangle",rectanglesize(82, 221, 26, 80),
            "color",htmlrgb("000000"),
            "name","",
            "TextSize","13 px",
            "ControlSize","Regular",
            "Procedure","resume {}",
            "$PushButtonStyle","Push Button",
            "Title","Stop"
        newformobject "PushButtonObject",
            "rectangle",rectanglesize(82, 319, 26, 88),
            "color",htmlrgb("000000"),
            "name","",
            "TextSize","13 px",
            "ControlSize","Regular",
            "Procedure","resume {}",
            "Title","Ok",
            "$PushButtonDefaultButton","1"
        newformobject "TextEditorObject",
            "rectangle",rectanglesize(44, 101, 22, 308),
            "color",htmlrgb("000000"),
            "name","Button.Ok",
            "$TextEditorTerminateReturn","1",
            "$TextEditorTriggerFinished","1",
            "$TextEditorEditWindowHeight","100",
            "$TextEditorEmptyPrompt","Enter text...",
            "Procedure","resume {}",
            "$TextEditorInsertionPoint","All",
            "$TextEditorDataMode","Field/Variable",
            "FieldName","__theText__",
            "$TextEditorBorderStyle","Bezel",
            "$TextEditorEditWindowWidth","100",
            "TextSize","13 px",
            "$TextEditorFocusRing","1",
            "Alignment","Left",
            "$TextEditorTerminateTab","0",
            "$TextEditorUpdateVariableEveryKey","1"
            //named Text Editor "Button.Ok" to return properly close the dialog
        newformobject "TextDisplayObject",
            "rectangle",rectanglesize(14, 99, 22, 308),
            "color",htmlrgb("000000"),
            "Formula","__thePrompt__",
            "TextSize","13 px",
            "$TextDisplayFormulaMode","Formula",
            "$TextDisplayAutoScaleSize","1",
            "$TextDisplayVerticalTextAlignment","Center",
            "Alignment","Left",
            "Font","#SystemBoldFont"
        selectnoobjects
        SuperObject "Button.Ok","Open"
        settrigger ""
    endif
endloop
setformoptions "",targetFormName,"DELETE",""
If dlgResult≠"Cancel"
    setparameter 2, __theText__
Else
    settrigger "Stop"
Endif
undefine __theText__, __thePrompt__
If info("trigger")="Stop"
    stop
Endif

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:


#11

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

b


#12

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

#13

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:

endloop

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

If dlgResult≠"Cancel"

setparameter 2, theText

Else

settrigger “Stop”

Endif

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

b


#14

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

B

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


#15

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.


#16

404 error for the download link


#17

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.


#18

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

thanks
b


#19

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


#20

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.