Solution for closeField problem
SimPLsol at aol.com
SimPLsol at aol.com
Wed May 30 20:37:55 EDT 2007
Jacque,
Thank you, again, for your help last night. I was about to give up on this
when your email arrived. It inspired me to try a little harder (like all night,
all morning, and most of the afternoon). I believe I now have a solution to
closing fields on OS X without moving to other fields.
Here is all of the code (with many of the non-working attempts commented out
- but retained for reference):
-- This was written because
-- OS X does not send a closeField
-- to the last (perhaps "only") field edited
-- if a button was clicked after the field was changed
-- (buttons do not get focus in OS X, so the field retains it);
on mouseDown
if (the tool is "browse tool") \
and ("Editor.ahm" is in the filename of this stack) \
and (word 1 of the focusedObject is "field") \
and (word 1 of the target is "button")
--and (word 1 of the name of the target is not "field") -- use "button"
only
then
--put the selectedField into vTempSelectedField
--put the focusedObject into vTempField
--put the short name of vTempSelectedField into vSelectedName
--put the short name of vTempField into vTempName
--send "closeField" to vTempField -- caused too much recursion
--put the selection into vSelectionHolder -- preserve the selection
focus on graphic "Floating Rectangle" -- removes the selection
--put the selection into vSelectionHolder2
--focus on ""
--focus on empty
--focus on btn "Lock Status"
--set the traversalOn of vTempField to false
--set the traversalOn of vTempField to true
--defocus vTempField
--deselect vTempField
-- setTheEditorLockStatusTo "!"
end if
pass mouseDown
end mouseDown
The two secrets are:
1. trigger this when the focusedObject is a field and the target is a button
(buttons only)
2. focus on a graphic (rather than a button or field)
So far, it seems to do everything as desired:
1. sends a "closeField" when a field is edited and a button is clicked
2. does not send the "closeField" if the field was focused but not edited
3. does not send any "closeField"s if a series of buttons are clicked
4. does not interfere with copy and paste.
Paul Looney
**************************************
See what's free at
http://www.aol.com.
More information about the use-livecode
mailing list