A Little Menu Issue

J. Landman Gay jacque at hyperactivesw.com
Sat Jul 19 11:40:32 EDT 2008


Len Morgan wrote:

> My problem is I can get the menu to display but it never goes away and 
> doesn't seem to call my menuPick handler either.

The menuMousebutton property should be set to zero. Check the button 
inspector to make sure that's the case.

> What could be up with this?  My field has a mouseUp handler for the 
> right click, and my button has a menuPick handler for the choice.

You need to call the popup command in a mousedown handler. Then in a 
menupick handler, deal with the menu selection. The field won't see any 
messages that come from the button; you'll have to send that info to the 
field after the button retrieves it.

> 
> Also, is there a way I can pass the line that was clicked on to the 
> popup command so that when a choice is made, my little "editor" can have 
> the number and name of the person that was selected?  Alternatively, can 
> I pass back the selection that was made to the field mouseUp handler and 
> let it remember which line the mouse was clicked on?

It works the other way around. The selected menu item text is passed to 
the menupick handler. Then you can do whatever you want with it. Here's 
a sample button script for a popup button named "myMenuBtn":

on mousedown
  popup "myMenuBtn"
end mousedown

on menupick pWhich
  put pWhich into theSelectedText
  -- now you have the user's choice; send it to the field, or whatever
end menupick

You can also use a switch statement in the menupick handler, just like 
any other menu, if that's easier for what you want to do.

The button's "menuhistory" property will store the last line that was 
selected in the button's menu. So if you want a line number, you can get 
it from the popup button directly:

  put the menuhistory of btn "myMenuBtn" into tLastLineNum

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list