So many ways in XTalks (was: Re: Contextual Menus)

Eric Chatonet eric.chatonet at sosmartsoftware.com
Thu Jul 24 05:37:22 EDT 2008


Bonjour à tous,

Le 24 juil. 08 à 07:49, Terry Judd a écrit :

> In your card or stack script
>
> ON mouseDown pMouseBtnNum
>     IF pMouseBtnNum = 3 THEN
>         IF word 1 of the target = "field" THEN
>             IF not(the locktext of the target) THEN
>                 popup btn "contextualMenu"
>             END IF
>         END IF
>     END IF
>     pass mouseDown
> END mouseDown

I could not resist ;-)
Rev allows many ways to script:
Here is the same as the above using a function.
What is interesting is that a function returns a value immediately  
when a condition matches and avoids using nested conditional  
structures or long statements with and/or.

on mouseDown pButton
   if PopupAllowed(pButton) then popup btn "contextualMenu" --
end mouseDown
------------------------------
function PopupAllowed pButton
   if pButton <> 3 then return false
   if word 1 of the target <> "field" then return false
   if the lockText of the target then return false
   return true
end PopupAllowed

Best regards from Paris,
Eric Chatonet.
----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------





More information about the use-livecode mailing list