I was intrigued by the suggestion made on this forum a while back for the gettext
window to be a sheet attached to the active window. I worked out a unique method to do this using a procedure that would be called from any another procedure. There are no permanent forms involved since the procedure will first create a new blank form, open it as a sheet attached to the current window, set the form options and then create all the form objects on the fly. When text has been entered and one of the buttons have been pressed or the editor closed the sheet window is closed and the form itself is deleted.
The calling format would be: call .gettextsheet theText, thePrompt
Once the call is made the new GetTextSheet would open on the form and operate as a normal GetText would operate but as a sheet instead. Here is what the GetTextSheet looks like in action:
The TextEditor opens with all existing text highlighted and ready to go. Hitting Enter or Return or the OK button will return the new text value while Stop returns the original text value. Here is the procedure code for the needed procedure you would name .gettextsheet. Of course this could be easily converted into a custom statement.
__TheText__=parameter(2)
__ThePrompt__=parameter(1)
local targetFormName
define targetFormName,"•••"
makenewform targetFormName
opendialogsheet "•••","Rectangle",rectanglesize(1,1,150,450)
restoreFormFromBlueprint:
setformoptions "",targetFormName,
"ALTERNATINGBACKGROUNDCOLORS",-1,
"BACKGROUNDCOLOR",htmlrgb("EDEDED")
makeFormObjectsFromBluePrint:
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"
newformobject "TextDisplayObject",
"rectangle",rectanglesize(14, 99, 22, 308),
"color",htmlrgb("000000"),
"Formula","__ThePrompt__",
"TextSize","14 px",
"$TextDisplayFormulaMode","Formula",
"$TextDisplayAutoScaleSize","1",
"$TextDisplayVerticalTextAlignment","Center",
"Alignment","Left",
"Font","#SystemBoldFont"
selectnoobjects
settrigger ""
SuperObject "Button.Ok","Open"
pause {}
SuperObject "Button.Ok","Close"
closewindow
setformoptions "","•••","DELETE",""
If info("trigger")="Button.Ok"
setparameter 2, __TheText__
Endif
undefine __TheText__, __ThePrompt__
return```
For convenience I have my test file available containing two procedures, the one shown above as well as another in the Action menu called GetTextSheet which will demonstrate how the call to .gettextsheet works in practice.
http://www.unseensoft.com/Gettextsheet.zip
I tried to make this version have the exact same look as the standard `gettext` statement but in a sheet format.