Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with enabling or disabling menu items

0 views
Skip to first unread message

Mohsen

unread,
May 9, 2008, 10:05:52 AM5/9/08
to

Hello,

The process of command enabling seems not to work properly when
there is a submenu in a main menu. To be more specific assume
that we have a File menu that has three items namely, new, save
and recent files. When the last item (recent files) is activated
it opens a submenu showing a few items. The problem is that if
the item preceeding recent files (save item) is disabled through
command enabling mechanism of OWL (EV_COMMAND_ENABLE &
TCommandEnabler) all items of submenu that pops up when clicking
on recent files will also be disabled regardless of disabling
its individual items using command enabling mechanism or not.
Any idea would be appreciated.

Mohsen

Jogy

unread,
May 9, 2008, 12:03:34 PM5/9/08
to

Hello, Mohsen,

can you check if there is overlapping of the menu and submenu IDs

Note that when you define a menu with subitems, it does not have
associate id:

POPUP "&Search"
BEGIN
MENUITEM "&Find...", CM_EDITFIND
MENUITEM "&Replace...", CM_EDITREPLACE
MENUITEM "&Next\aF3", CM_EDITFINDNEXT
END

But there is an OWL convention, which uses a command enabler
for id equal to the id of the first subitem minus 1,
in this case (CM_EDITFIND - 1) can be used to disable the whole
"&Search" menu.


Try to change the ids of the items in the submenu,
and see if the problem still occurs.

Jogy


Mohsen

unread,
May 12, 2008, 11:27:59 AM5/12/08
to

>Hello, Mohsen,
>
>can you check if there is overlapping of the menu and submenu IDs
>
>Note that when you define a menu with subitems, it does not have
>associate id:
>
> POPUP "&Search"
> BEGIN
> MENUITEM "&Find...", CM_EDITFIND
> MENUITEM "&Replace...", CM_EDITREPLACE
> MENUITEM "&Next\aF3", CM_EDITFINDNEXT
> END
>
>But there is an OWL convention, which uses a command enabler
>for id equal to the id of the first subitem minus 1,
>in this case (CM_EDITFIND - 1) can be used to disable the whole
>"&Search" menu.
>
>
>Try to change the ids of the items in the submenu,
>and see if the problem still occurs.
>
>Jogy
>
>
Hello Jogy,

I have already checked menu items for overlapping ID's. There
is certainly no overlap. I've included a brief part of my
resource to show exactly where the problem resides. Consider
the following resource items:

#define CM_ASSIGNSECTION 326
#define CM_MINIMALACS1 327
#define CM_MINIMALACS2 328
#define CM_MINIMALACS3 329
#define CM_MINIMALACS4 330
#define CM_MINIMALACS5 331
#define CM_FUNDAMENTALCYCLES 332
#define CM_MINIMALCYCLES 333
#define CM_OPTIMALACS 334
#define CM_CONDITIONEDACS 335
#define CM_BASISLENGTH 336
#define CM_INDEPENDENCE 337
#define CM_ORDERCYCLES 338
#define CM_ADJACENCYPATTERN 339
#define CM_NONZEROELEMENTS 340

POPUP "&Assign"
{
POPUP "&Element"
{
MENUITEM "&Section...", CM_ASSIGNSECTION
}
}

POPUP "&Structure"
{
POPUP "Minimal Cycles using &ACS"
{
MENUITEM "Variant &One", CM_MINIMALACS1
MENUITEM "Variant &Two" CM_MINIMALACS2
MENUITEM "Variant T&hree", CM_MINIMALACS3
MENUITEM "Variant &Four", CM_MINIMALACS4
MENUITEM "Variant F&ive", CM_MINIMALACS5
}
MENUITEM "&Fundamental Cycles", CM_FUNDAMENTALCYCLES
MENUITEM "&Minimal Cycles", CM_MINIMALCYCLES
MENUITEM "Op&timal Cycles using ACS", CM_OPTIMALACS
MENUITEM "Conditioned Cycles using ACS", CM_CONDITIONEDACS
MENUITEM SEPARATOR
MENUITEM "Cycle &Basis Length", CM_BASISLENGTH
MENUITEM "Check &Independence", CM_INDEPENDENCE
MENUITEM SEPARATOR
MENUITEM "&Order Cycles", CM_ORDERCYCLES
MENUITEM SEPARATOR
MENUITEM "Adjacency &Pattern", CM_ADJACENCYPATTERN
MENUITEM "&Number of Nonzero Elements", CM_NONZEROELEMENTS
}

and the following code to enabale/disable "Element" and
"Minimal Cycles using ACS" sub menus:

case CM_ASSIGNSECTION:
ce.Enable(selectedElements->GetItemsInContainer() > 0);
break;

case CM_MINIMALACS1:
case CM_MINIMALACS2:
case CM_MINIMALACS3:
case CM_MINIMALACS4:
case CM_MINIMALACS5:
case CM_FUNDAMENTALCYCLES:
case CM_OPTIMALACS:
case CM_CONDITIONEDACS:
ce.Enable(structure->GetNumNodes () > 0 &&
structure->GetNumElements() > 0);
break;

case CM_MINIMALCYCLES:
case CM_BASISLENGTH:
case CM_INDEPENDENCE:
case CM_ORDERCYCLES:
case CM_ADJACENCYPATTERN:
ce.Enable(structure->GetNumCycles() > 0);
break;

case CM_NONZEROELEMENTS:
ce.Enable(structure->IsPatternAvailable());
break;

If the condition that enables the "Elements\Section" item
(CM_ASSIGNSECTION) is not true and thus disabling the item, all
items corresponding to "Minimal Cycles using ACS" submenu will
also disable and the code corresponding to enabling this
submenu does not execute at all!

Mohsen

Mohsen

unread,
May 12, 2008, 11:44:15 AM5/12/08
to

>
>Hello, Mohsen,
>
>can you check if there is overlapping of the menu and submenu IDs
>
>Note that when you define a menu with subitems, it does not have
>associate id:
>
> POPUP "&Search"
> BEGIN
> MENUITEM "&Find...", CM_EDITFIND
> MENUITEM "&Replace...", CM_EDITREPLACE
> MENUITEM "&Next\aF3", CM_EDITFINDNEXT
> END
>
>But there is an OWL convention, which uses a command enabler
>for id equal to the id of the first subitem minus 1,
>in this case (CM_EDITFIND - 1) can be used to disable the whole
>"&Search" menu.
>
>
>Try to change the ids of the items in the submenu,
>and see if the problem still occurs.
>
>Jogy
>
>
>
Hello Jogy,

Thanks for your help. I guess I got the point. You mean that
the id (CM_EDITFIND - 1) is assigned to the "Search" menu and
is used to disable/enable the whole menu. In this sense I
guess I do have overlaps. I'll remove them to see if the
problem still shows up or not.

Mohsen

0 new messages