I have rewritten the procedure to use the more standard rundialog
statement taking advantage of the Dialog.Initialize trigger to populate the form. Also added a trap at the beginning in case the form was never deleted in a previous use. Note the use of a rectangle set to 0% opacity which is added to keep a background click from closing the Text Editor & dialog inadvertently. Note also that the Text Editor is named “Button.Ok” which will force the dialog to close when the Text Editor is closed. Finally, I also changed the name of the newly created form to “•|•|•” to further reduce the likelihood another existing form may be similarly named. You could change this to any name you want since it will never be displayed anywhere. Here is the revised procedure:
__theText__=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__
Endif
undefine __theText__, __thePrompt__```
I notice on **Bitbucket #489** that Jim mentioned he intended for some time to make his own sheet version of `GetText` so this might all be an exercise in futility, but an enjoyable endeavor nonetheless on my part .