Hello everyone,
When you press return in a text field, the entire contents of the text field gets selected (at least in cases I have seen).
I have a script which tries to catch the return key and do something else - in my case, move to the next field (as one does with the tab key).
However, using the “keyboard up” handler, it appears that my code doesn’t reach the text field until after it has selected the contents of the field. The result is an annoying visual effect: the contents of the field is completely selected, then the first responder moves to the next text field.
I have tried things like “return true” or “return false” in the “keyboard up” handler but neither seem to prevent the effect of the return key on the selection of the text field.
Is there any way to catch the return key and stop it from selecting the contents of the field before doing anything else?
on keyboard up theObject event theEvent
set theKeyPressed to (character of theEvent)
if the name of the window of theObject is "windowCollection" then
if theKeyPressed is return then
(* The return key was pressed. Move to the next field *)
if the name of theObject is "editField4" then
(*Create a new entry *)
tell button "addEntry" of view "editView" of split view "vertSplit" of view "rightHalf" of split view "horizSplit" of main window to perform action
return true
else if the name of theObject is "editField1" then
set the first responder of main window to text field "editField2" of view "editView" of split view "vertSplit" of view "rightHalf" of split view "horizSplit" of main window
return false
else if the name of theObject is "editField2" then
set the first responder of main window to text field "editField3" of view "editView" of split view "vertSplit" of view "rightHalf" of split view "horizSplit" of main window
return true
else if the name of theObject is "editField3" then
set the first responder of main window to text field "editField4" of view "editView" of split view "vertSplit" of view "rightHalf" of split view "horizSplit" of main window
return true
end if
end if
end if
end keyboard up
Model: MacBook Pro
Browser: Safari 525.18
Operating System: Mac OS X (10.5)