closeField and exitField problem

Phil Davis revdev at pdslabs.net
Mon Oct 15 15:27:00 EDT 2007


Hi Dave,

How about something like this:


-- in the card or stack script if needed by multiple fields

on openField
  detectCloseField (the long id of the target)
end openField

on closeField
  -- first do whatever needs to be done at closeField time
  -- then turn detector off immediately after
  send "closeFieldDetected" to the target in 0 seconds
end closeField

on detectCloseField pTargetID
  insert script of btn "detector" into front
  put pTargetID into vTargetField -- a local or global that's available 
to other handlers
end detectCloseField

on closeFieldDetected
  remove script of btn "detector" from front
  put empty into vTargetField
end detectCloseField


-- script of btn "detector" - a hidden, disabled button

on mouseDown
  if vTargetField <> empty then -- we have a situation
    send "closeField" to vTargetField
  end if
  pass mouseDown
end mouseDown


Sorry - sometimes it's easier to code it than 'splain it! I haven't 
tested this so let the buyer beware.

HTH -
Phil Davis



Dave wrote:
> Hi,
>
> I asked about this problem ages ago, but didn't get a response, so I'm 
> asking again as it's just come up again!
>
> I am running on a Mac. If the user fills in a field and then tabs out 
> of the field, either a closeField or exitField message is sent to the 
> field. All well and good. However, if the user clicks on a button, 
> nether messages are sent!
>
> This is supposedly normal behavior since from the docs:
>
> "If the lookAndFeel property is set to "Macintosh", the closeField 
> message is generally not sent when another control (such as a button) 
> is clicked. This is because clicked buttons do not receive the focus 
> on Mac OS systems, and therefore the selection remains active."
>
> (incidentally, in this case the "lookAndFeel" and feel property is set 
> to "Appearance Manager", so according to the above it should still 
> send the message(s).)
>
> This effectively means that it\s impossible to ensure that a field is 
> valid using these messages, so what's the use of having them or am I 
> missing something.
>
> I want to let the user enter a number of fields and then when the user 
> clicks the button, I check to see if they are valid and if not put if 
> an error message. The problem is that the three field must be examined 
> together, so I'd like to be able to store the contents of each field 
> in a custom property of the stack and then check them in the mouseUp 
> handler of the button. I can't really access the fields directly (as 
> is put field "XXX" into whatever) since the check may be run on a 
> different card and it's really horrible to access fields like that.
>
> Any ideas or suggestions would be greatly appreciated!
>
> All the Best
> Dave
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list