Forums

Find answers, ask questions, and connect with our
community all around the world.

Home Forum Omnis General Forum Accessing Sub-Menu Hierarchy

  • Accessing Sub-Menu Hierarchy

    Posted by Kevin Martin on January 6, 2024 at 5:25 pm

    I am trying to figure out how to access the sub-menu hierarchy of a menu system installed on a window’s menu bar. A simple part of this is visually appears/acts like this: Primary–>Print–>This Group or All Groups. With certain application conditions I wish to disable the “All Groups” option within the Print sub-menu. However, the Notation Inspector shows nothing beyond $iwindows.frmMenuTest.$menus.mnuPrimary.$objs.cmdPrint. How do I notationally access the sub-menu to change the enablement of one of its lines?

    P.S. I tested a bunch of different combinations to see if I could figure this out. The only thing that worked was resetting the $cascade property of cmdPrint empty, changing $enabled property of the desired mnuPrint line at the library level (Do $clib.$menus…) and then re-assigning the $cascade property to its original value. This is an extremely tedious work-around and has a number of disadvantages.

    Kevin Martin replied 6 months, 2 weeks ago 2 Members · 5 Replies
  • 5 Replies
  • Andreas Pfeiffer

    Administrator
    January 7, 2024 at 3:13 pm

    Hi Kevin,

    you may be interested in the following technical note: https://www.omnis.net/developers/resources/technotes/tngi0001.jsp

    Depending on what you are trying to achieve it might be probably better to put the responsibility on how the menu is going to act right into the menu itself rather trying to control it from the outside. Please see the following technical note that describes this: https://www.omnis.net/developers/resources/technotes/tngi0022.jsp

    Hope this helps.

    Best,

    Andreas

  • Kevin Martin

    Member
    January 7, 2024 at 4:56 pm

    Andreas,

    Thanks for the quick response. Unfortunately, TNGI0001, “Cascaded Menu Instances” is lacking examples of how to use the $menuinst and it does not appear in the Notation Inspector (see the attached screen shot). Using the Notation Inspector, I was able to see the runtime property of $menuinst associated with the cascaded menu line and it shows “not empty”, but we are not allowed to view its content!

    The article says that $menuinst is a reference to the cascaded menu. So, I tried a couple of different iterations to manipulate it, but was unsuccessful.

    I don’t believe that what I’m trying to do is all that radical. Menus change the status of their menu lines on a regular basis in response to application conditions. For example, the OS standard Edit menu changes the status of Cut, Copy and Paste based on changing conditions. Similarly, I have menus that need to enable/disable menu lines based on application conditions.

    Kevin

  • Kevin Martin

    Member
    January 7, 2024 at 4:58 pm

    Andreas,

    Just to clarify, with my test window started, I could see the runtime $menuinst property in the properties of the window, not in the Notation Inspector. As stated, there is no evidence of the cascaded menu in the Notation Inspector.

    Kevin

  • Kevin Martin

    Member
    January 9, 2024 at 7:32 pm

    Andreas,

    Thanks for the help! That worked for me, too, in my test environment. I also had inquired directly of Bob Mitchell, who authored the Tech Note you referenced. Bob responded with a very similar solution.

Log in to reply.