Table behavior

Cubist at aol.com Cubist at aol.com
Tue Apr 5 23:34:02 EDT 2005


sez boinjyboing at hotmail.com:
>I have just started playing around with fields that have "table" behavior.
>I was planning on writing a little spreadsheet program. However, it appears
>that the closeField message is not sent to the field when its behavior
>is like a Table. 
>
>This can be demonstrated: create a new Table from the toolbox. Put this
>in its script:
>on closefield
>  answer "closefield was called"
>end closefield
>When the user edits a cell and then clicks on a different field, no message
>is sent.
>But when the "Cell Editing" property of the field is turned off, then the
>message is sent as I expected.
>
>I'd like to know when the data in the field changes. But if closefield
>doesn't work (and exitfield is sent only when data is not changed) then
>what do you use?
   Something like this in the script of that field might work:

  local OldData,ImInside
  local Intervl = 50

  on  mouseEnter
    set the OldData of me to me
    set the ImInside of me to true
    set the ItzChanged of me to false
    send "CheckForChanges" to me in Intervl milliseconds
    WhateverElseYouDoOnME
  end MouseEnter

  on CheckForChanges
    set the ItzChanged of me to (me <> OldData)
    if (the ImInside of me) then
      send "CheckForChanges" to me in Intervl milliseconds
    else
      set the ImInside of me to false
    end if
  end CheckForChanges

   With this code, your field gets an ItzChanged property, updated in 
20-times-a-second realtime, that is "true" if the field's content differs from what 
it was at the time the mouse entered the field, and "false" if the field's 
current content is unchanged from what it used to be. You can use "the ItzChanged 
of field Whatever" to make use of this information in any other script/handler 
you like.

   Hope this helps...


More information about the use-livecode mailing list