Now from the “let’s see if can be done” department. I came up with a brute force work-around for the escape key not highlighting the Cancel button when closing the dialog window. My approach has the Cancel button named cancelButton and the OK button named okButton so that I can use the changeobject statement to do the highlighting. The actual highlight is accomplished by turning the default option temporarily on for the Cancel button and off for the OK button and then both back again.
The mechanics involve trapping the escape character and executing the changeobject code and then repeating the loop so it finishes normally. There are also traps to adjust things if the escape key was already the last key pressed when the dialog was opened.
This example assumes the form used for the dialog is named Dialog containing the two buttons mentioned above and properly named.
local escapeCheck, escapeTrap, escapeState
escapeCheck=asc(info("keyboard"))
escapeState=?(escapeCheck=27,1,0)
loop
rundialog {Form=Dialog Sheet=TRUE Height=120 Width=400}
escapeTrap=0
If (asc(info("keyboard"))=27 and escapeCheck ≠ 27) or (escapeState=1
and info("trigger")="Dialog.Cancel")
changeobject "cancelButton",
"$PushButtonDefaultButton","1"
showpage
changeobject "okButton",
"$PushButtonDefaultButton","0"
showpage
changeobject "cancelButton",
"$PushButtonDefaultButton","0"
showpage
changeobject "okButton",
"$PushButtonDefaultButton","1"
showpage
escapeCheck=27
escapeTrap=1
escapeState=0
Endif
repeatloopif escapeTrap=1
stoploopif info("trigger")="Dialog.Close"
endloop
Regarding the Return and Enter key not activating a default button if there is no Text Editor on the form, experimenting on my iMac with a Macally extended keyboard showed that only a Command-Enter or a Control-Enter combination will trigger the default button. No other key combination with the Enter or Return keys are recognized.