Determining which menu button was clicked on Mac

Frank Leahy frank at backtalk.com
Tue Jan 13 14:18:47 EST 2004


Two comments -- see below:


On Tuesday, January 13, 2004, at 05:00 PM, 
use-revolution-request at lists.runrev.com wrote:

> I would set script of  the menubutton to :
>
> on menuPick pWhich
>    put the text of me into TESTO
>
>    switch pWhich
>    case (line 1 of TESTO)
>
>      if line 1 of TESTO is "play" then
> -- do something
>        put "stop" into line 1 of TESTO
>      else
>        put "play" into line 1 of TESTO
> -- do something
>      end if
>      set the text of me to TESTO	
>      break
> 	
>    case (line 2 of TESTO)
>      beep 1
>      break
>    end switch
>
> end menuPick
>
> However it would be very useful to have  a "MenuPickNumber"  returned
> by Revolution any time a menu item (or a sub-menu item) has been
> clicked,
> So, we could easily change the text of the button  and let the script
> unchanged (for example when we have a menu issued in different
> languages).
>
> Best regards
>
> Paolo Mazza
>

There's no reason to test for the current menu item values -- RR will 
return the correct menu item name, depending on what was in it when the 
user chose it.  If you had it set to "Stop" then simply call your stop 
function, if you had it set to "Play" then simply call your play 
function.  Make sense?
>
>
> Giovedì, 8 Gen 2004, alle 06:40 Europe/Rome, Trevor DeVore ha scritto:
>
>> On Jan 7, 2004, at 6:26 PM, Björnke von Gierke wrote:
>>
>>> I had a similar problem like you, where I wanted to check/unckeck a
>>> menu item before the menu is shown. And indeed I was unable to do
>>> this anywhere else then the menubar group's script on OS X. I worked
>>> around this by using a "if the target = "view" then" script. It might
>>> be time for a feature request?
>>
>> Where would you put the 'if the target = "view" then' script?  I tried
>> checking 'the target' in the menubar group script but it returned the
>> name of the menubar group rather than the name of the menu that was
>> selected.
>>

In terms of when you have to set the menu items -- a very long time ago 
I wrote the Menu Manager for the Mac II, and unless something drastic 
has changed under OSX, there's no way to change menu item names "on the 
fly", i.e. while a menu is down (not without writing your own 
MenuDefProc).  That means that you have to set the menu items before 
the menu goes down.   The right place to do this is in the menu's (or 
menubar's) mouseDown handler.  Make sure to "pass mouseDown" after 
you've set your menu items.

-- Frank



More information about the use-livecode mailing list