Another Script Editing Tip

Scott Rossi scott at tactilemedia.com
Tue Jul 1 17:25:01 EDT 2003


Recently, "Howard Bornstein"  wrote:

> I had this script in my home stack:
> 
> on mousewithin
> global currentTarget
> put the target into currenttarget
> if currenttarget contains "field"  then
>   if the commandkey is down and the shiftkey is down then
>     set locktext of currenttarget to not locktext of currenttarget
>     wait 20 -- just so you don't toggle it on and off if someone
>     -- leaves the option key down
>   end if
> end if
> end mousewithin
> 
> This script doesn't work in Revolution (unless it's in the actual field
> you're trying to affect. It won't work in the stack script.)
> 
> Apparently the mousewithin message doesn't travel up the hierarchy like
> it does in HC. Can you tell me why?

Can't tell you why, but according to the MC docs, mouseWithin is yet another
inefficient handler to be avoided.

The following works similarly to the HC script above and uses two key sets
(command+shift = unlock,command = lock):

[can be placed in the card or stack script]

on mouseMove
  if word 1 of name of the target = "field" then
    if the commandKey is "down" then
      if the shiftKey is "down" then
        set the lockText of the target to false
      else set the lockText of the target to true
    end if
    # SHOW FIELD STATUS
    put name of the target && "locked = " && the lockText of the target
  end if
end mouseMove

Passing the mouse over the field with the above mentioned key combinations
pressed allows you to lock/unlock a field at will.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com




More information about the use-livecode mailing list