PopUp Menus

Jan Schenkel janschenkel at yahoo.com
Tue Nov 19 04:33:01 EST 2002


--- doupsy at wanadoo.fr wrote:
> Hello,
> 
> Is it possible to track a menuitem which have
> (sub)menuitems with mouseedown.
> For example, I have in my popup button this :
> 
> A
> <tab>A1
> <tab>A2
> <tab><tab>A21
> <tab><tab>A22
> <tab><tab>A23
> <tab>A3
> B
> C
> D
> <tab>D1
> 
> 
> After mousedown, I should like to track for example
> the A2 menuitem. 
> How is it possible ? (menuPick ? menuHistory ?
> others ?).
> I should like to know also how to track nothing (if
> after mousedown i 
> don't want to choose a menuitem and I put the cursor
> out of the menu 
> and I mouseup).
> 
> Thanks
> 
> Edouard
>

Bonjour Edouard,

After the user has made his selection from your popup
menu, the button will be sent a 'menuPick' message.
The easiest way to handle these is a switch structure,
like this one:

on menuPick pWhichItem
  switch pWichItem
  case "Foo"
    put "Foo"
    break
  case "Bar"
    put "Bar"
    break
  end switch
end menuPick

The trick with hierarchical menus is that pWhichItem
is a composition of the item, sub-item and
sub-sub-item you picked, sepoarated by a "|".
So in the above menu structure, if the user selects
item "A23", the engine sends a menuPick to your button
with as parameter "A|A2|A23"

In conclusion, your menuPick handler should look
something like:

on menuPick pWhichItem
  switch pWichItem
  case "A|A1"
    -- do whatever is appropriate
    break
  case "A|A2|A21"
    -- do whatever is appropriate
    break
  case "A|A2|A22"
    -- do whatever is appropriate
    break
  case "A|A2|A23"
    -- do whatever is appropriate
    break
  case "A|A3"
    -- do whatever is appropriate
    break
  case "B"
    -- do whatever is appropriate
    break
  case "C"
    -- do whatever is appropriate
    break
  case "D"
    -- do whatever is appropriate
    break
  end switch
end menuPick

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com



More information about the use-livecode mailing list