How do I hide a TGPopupMenu?

I use TGPopupMenu::AddEntry(“text”,M_ID) to create menu items all the time. I can hide them with HideEntry(M_ID) if I desire. My question is: If I add a popupmenu as a menu item, e.g. TGPopupMenu::AddPopup("cascadtext",*pCascadeMenu) where pCascadeMenu is a pointer to another TGPopupMenu, how do I hide pCascadeMenu? Thanks!

I am using Root 5.06/00 on XP. Thanks!

Ed

Hi Ed,

Cascaded menu groups related menu choices together in a sub-menu to reduce the number of menu entries displayed in the parent popup menu. They are always enabled. This standard behavior is implemented in our code. If you need to disable all entries of a cascaded menu, better group them between separators and put them in a parent popup menu. Users have to be informed what is available and what not in the application. If we hide a cascaded menu, the parent menu entry is not able to provide all necessary information about the choices it gives to the users.

Cheers, Ilka

Hi Ed,

  1. create a new class derived from TGPopupMenu and add missing functionality
    (in case of success, do not forget to send a code to rootdev :slight_smile: )

    • get entries list by TGPopupMenu::GetListOfEntries
    • iterate through the list of entries to find the entry of interest
      (you can check entry’s name and type).
    • assign some unique ID to this entry (do not forget to request rootdev to add
      a new setter method to TGMenuEntry class :slight_smile: )
    • apply TGPopupMenu::HideEntry method as usually

HTH.

Regards. Valeriy

If you have only one cascaded popup menu, use such a trick

TGPopupMenu::HideEntry(-2);

:smiley:

Dear Valeriy,

“In general, today’s graphical systems follow the gray-out approach for inactive menu choices. A menu should provide all relevant alternatives, and only relevant alternatives, at the point at which it is displayed” Wilbert O. Galitz

A trivial example, open a new MS Word document, select ‘Table’ menu / ‘Select’ submenu. The submenu appears with all menu items in gray because there is no table created in the document. Hiding menu entries after the menu creation is not good for users. Imagine you are in a furnished room. For a moment you look outside via the window, after you turn back and a part of the furniture is missing. That is confusing, isn’t it?

Cheers, Ilka

Dear Ilka,
do I understand correctly, that ROOTdev rejects to implement this request
because this ignores “Wilbert O. Galitz recomendations” and “MS Word” GUI style?
IMHO, it’s less than 15minutes of work to imlement this feature
(less “efforts” than keeping this discussion).
I think it’s up to user, to hide menu entry or not. The responsibility of ROOTdev is
to provide this possibility.

For a long time ROOT has been “user-requests-driven” project.
I missed the moment when it has been changed.

Hi Valeriy,

The essential GUI guide written by Galitz summarizes the results of many years collected experience on the field of Human-computer interaction. These rules are followed by the developers of GUI toolkits because they guarantee the usability and easy-use of created applications. I see nothing wrong to follow them in ROOT GUI classes. It is better to prevent users from writing less usable applications by avoiding such functionality. There is a method for hiding menu entry, we are talking about a special entry related to a cascaded menu. Please provide application examples where cascaded menus are hidden and shown ‘on fly’.

Cheers, Ilka