What's On The Menu - Round 2

Peter Haworth pete at lcsql.com
Tue Jan 1 12:56:02 EST 2013

Continuing my quest to understand some of the fine points of menu handling
with cascading items in LC, I'm now focusing on popup menus.

The contents of the menu in question are set up dynamically in a mouseDown
handler and some data conditions can cause either a checkmark or a diamond
to appear immediately before some of the cascading items (all using that
standard !c and !r notation).  No problem, all works fine.

Now the user picks a cascading item from the popup menu and in my menuPick
handler, I need to discover if the selected item has a check mark or a
diamond before it because my handling of the selected item
is different based on their presence or absence.

First problem.  The parameter to menuPick does not include any indication
of whether the selected item has a checkmark or diamond before it.

OK says I, that seems strange but no problem, I will use the menuHistory to
get the line of the popup menu text that was selected and look for either
!c or !r in it.

Second problem.  The menuHistory contains a line number that does not
relate in any way to the line number that was selected.  Not even to the
primary line that contained the cascading item.

In fairness, heaving read the dictionary entry for menuHistory after the
fact, it does say that the menuHistory is "ambiguous" for cascading items.
 "Ambiguous"?  Maybe flat out incorrect would have been a better
description but by now I've come to realize that stuff like this will never
het changed in LC even if it's accepted as a problem because "it might
break existing applications".

I can  think of at least a couple of ways round this problem, by repeating
the check that caused the checkmark or diamond to be placed there
initially, or by somehow recording the actual text lines that contain a
checkmark/diamond in a custom property of the menu.

Are there any other recommended ways to get round this?

lcSQL Software <http://www.lcsql.com>

More information about the use-livecode mailing list