So many ways in XTalks (was: Re: Contextual Menus)
Ken Ray
kray at sonsothunder.com
Thu Jul 24 12:26:54 EDT 2008
> Rev allows many ways to script:
Agreed!
> 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
I would also put this in a frontScript instead of a card/stack script in the
event you need to use the mouseDown in a field for other reasons. The only
real difference is to add the "pass mouseDown":
on mouseDown pButton
if PopupAllowed(pButton) then popup btn "contextualMenu"
else pass mouseDown
end mouseDown
This way, if the user right-clicks/Control-clicks, the popup menu displays,
otherwise the target field gets the mouseDown message that it can do with as
it likes.
Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the use-livecode
mailing list