Menu "QUIT" item

  1. 7 weeks ago

    I would like to be able to add an item to the menubar that will execute code immediatly when the user selects the "Item" and not open up sub menu items?

    Basically the menu item is a "Push Button"
    Thanks
    jim

  2. Greg O

    May 21 Xojo Inc scout.galaxy.barn

    Could you elaborate? Reading your subject line and your explanation seem to be in conflict as Quit menu items typically don’t have subitems. Maybe a picture would help?

  3. Paul L

    May 21 Xojo Inc, Third Party Store

    I also am not quite sure what you mean. Code in the Menu Handler for the menu is execute when the menu is selected without displaying anything else automatically.

    More information about menus is here:
    https://docs.xojo.com/UserGuide:Desktop_Menus

  4. Tim S

    May 21 Testers Canterbury, UK

    I'm guessing that he wants an event to happen when the user selects the menu, even if all the user does is look at it when it drops down, and then clicks to deselect the menu - that is even if the user does not select a menu item. BICBW.

  5. 6 weeks ago

    Emile S

    May 21 Europe (France, Strasbourg)

    Nothing happens when you select a Sub-Menu (with SubMenuItems enabled) and you release the mouse.

    First time I saw one asking for that.

    What about a SubMenuItem that do that instead ? (same name of the SubMenu)

  6. Scott C

    May 21 Testers, Xojo Pro twitter.com/ScottCadillac
    Edited 6 weeks ago

    @Tim S I'm guessing that he wants an event to happen when the user selects the menu, even if all the user does is look at it when it drops down, and then clicks to deselect the menu - that is even if the user does not select a menu item.

    My interpretation is similar, except I think @Jim M is looking to have the Event happen on the MenuItem in the bar itself, but not open a submenu.

    I just tried an example of adding only a "top" MenuItem (called "Click Me" in the following screen-shot) and an Menu Handler, but strangely the handler does nothing (breakpoint was not called either), and I can't easily see how to identify "which" MenuItem was clicked that triggers the EnableMenuItems Event.

    -image-

    At least that's what I thought he was looking for.

  7. Ivan T

    May 21 Testers

    @Jim M I would like to be able to add an item to the menubar that will execute code immediatly when the user selects the "Item" and not open up sub menu items?

    Basically the menu item is a "Push Button"
    Thanks
    jim

    That is easy!

    Just add a menu bar to the proyect or use the default one, Edit it to add your top level item

    asign this menu bar to the window in the ispector

    In the navigator (left of the IDE) right the window, click add, Menu handler

    Select the menu handler and choose your item in the inspector

    that is all, just write your code to the handler

  8. Dale A

    May 21 San Diego, California, USA

    If the menuitem in question has a submenu, I don't believe that you can prevent it from displaying the submenu when clicked. If you create an item in the top menubar and don't add submenu items to it, you can define a menuhandler for that item. In that case, it will act as if it were a pushbutton in the menubar. Once you add a submenu to it, however, you cannot create a menuhandler for the top item and if you had already created one, it will no longer be called.

    At least that's what happens on Windows.

  9. Scott C

    May 21 Testers, Xojo Pro twitter.com/ScottCadillac

    @Ivan T Select the menu handler and choose your item in the inspector

    that is all, just write your code to the handler

    @Dale A If you create an item in the top menubar and don't add submenu items to it, you can define a menuhandler for that item.

    That's what I tried, but the handler doesn't appear to fire.

    At least not on macOS 10.15.3 using 2019r3.1.

  10. Ivan T

    May 21 Testers

    @Scott C That's what I tried, but the handler doesn't appear to fire.

    At least not on macOS 10.15.3 using 2019r3.1.

    I tested in windows ad it works. Maybe it is a xojo BUG on macOS

  11. Tim P

    May 21 Testers, Xojo Pro Rochester, NY
    Edited 6 weeks ago

    @Ivan T Maybe it is a xojo BUG on macOS

    It's an intentional (macOS) design decision I'm pretty sure. I think there was even originally a note about OPs design request in the way old HIG books. (saying something like "don't do this")

  12. Scott C

    May 21 Testers, Xojo Pro twitter.com/ScottCadillac
    Edited 6 weeks ago

    @Ivan T I tested in windows ad it works. Maybe it is a xojo BUG on macOS

    Well, I'll be... it does work on Windows, but not macOS.

    @Tim P It's an intentional (macOS) design decision I'm pretty sure. I think there was even originally a note about OPs design request in the way old HIG books. (saying something like "don't do this")

    That wouldn't surprise me. I'm pretty sure I have seen this kind of thing in other Windows apps in the past, but maybe not in an Mac app.

    Just to be complete, I did search for a similar case in Feedback, but upon not finding anything obvious I tried to submit a "bug" report - but Feedback wouldn't let me. So I'll post a link to my example here and see if @Greg OLone or @Paul L have time to chime-in with their opinion.

    MenuBarClick.xojo_binary_project

    Note: I also looked at the MenuItem documentation, but I couldn't find any mention of this particular use-case among the other Mac specific stuff. But maybe I missed it.

  13. Arnaud N

    May 22 Testers, Xojo Pro A lost country in Switzerland.

    @Scott C Well, I'll be... it does work on Windows, but not macOS.

    I would say it works on macOS but not on Windows, especially because, once you fill and empty the menu, the behaviour differs between before and after (=inconsistency). A menu bar isn't a toolbar: there are no such things as “buttons” there.

  14. Sorry for not responding eariler.

    Scott C's post yesterday with the picture is exactly what I'm trying to do.

    Thanks Scott C for clarifying.. :)

    I am in macOS

  15. Tim S

    May 22 Testers Canterbury, UK

    Then presumably you can't do it.

or Sign Up to reply!