Unlocked field receives the mouseUp message

Jim Hurley jhurley0305 at sbcglobal.net
Mon Nov 28 17:44:21 EST 2011


Thanks Peter.

Actually i do want to just toggle the locktext of the field.

I use the field to proofread the text by reading from  the clickchunk to the end using revspeak.

If I encounter an error while speaking, I want to be able to easily click the field again to allow for edit. The control click does allow a mouseUp to get through and the locktext to be changed to allow for edit.

In retrospect, I should have understood the rationale for this  behavior. While editing text in an unlocked field it should be possible to copy and past into the field so that it has to respond to command, control keys etc. So, it doesn't respond to a naked mouseUp, but it will respond to a combination of command, control etc. mouseUP.

It saves my bacon.

Jim

> I have the following in a frontscript, so it works on any field:
> 
> on mouseup theBtn
>    if theBtn <> 1 then pass mouseup
>    if the target begins with "field" then
>       if the commandkey is down and the shiftkey is down then
>          set the writable of the target to not the writable of the target
>       end if
>    else
>       pass mouseup
>    end if
> end mouseup
> 
> setprop writable tf
>   if not (the target begins with "field") then exit writable
>   try
>     set the locktext of the target to not tf
>     set the traversalon of the target to tf
>     set the autohilite of the target to tf
>   end try
> end writable
> 
> getprop writable
>   if "field" is not in the target then return empty
>   try
>     put the locktext of the target into L
>     put the traversalon of the target into T
>     put the autohilite of the target into A
>     if T and A and not L then return true
>     return false
>   end try
> end writable
> 
> Holding the commandkey down during a mouseclick will trigger a mouseup message (like the controlkey), and this means that cmd-sh-click will trigger the mouseup handler. I use the virtual property "writable" to set the locktext, autohilite, and traversalon of the field. Note that no enduring property of the target field is ever actually set, since the calls are intercepted to perform an action on the field instead. This is what is meant by a "virtual" property. If you only want to toggle the locktext of the field you can instead forget the virtual prop calls and just do "set the locktext of the target to not the locktext of the target" in the mouseup handler.
> 
> -- Peter
> 
> Peter M. Brigham
> 
> pmbrig at gmail.com
> http://home.comcast.net/~pmbrig




More information about the use-livecode mailing list