haxeui / haxeui-core

The core library of the HaxeUI framework
http://haxeui.org
MIT License
340 stars 70 forks source link

stop closing menu when clicking on menu checkBoxes and optionBoxes #596

Closed Shallowmallow closed 5 months ago

Shallowmallow commented 5 months ago

Felt weird that the menu closes when clicking in a menu checkbox and menu option box. The fix stops dispatching the MenuEvent.MENU_SELECTED in case of MenuCheckBoxes and menuOptionBoxes. I don't think it's a loss as CHANGE events work for them, but maybe it is?

<vbox width="100%" height="100%">
    <menubar width="100%">
        <menu text="Normal">
            <menuitem text="Item 1" shortcutText="Shortcut" />
            <menuitem text="Item 2 (disabled)" disabled="true" shortcutText="Ctrl+A" />
            <menu text="Sub Menu">
                <menuitem text="Item 1" />
                <menuitem text="Item 2" />
                <menuitem text="Item 3" />
                <menuseparator />
                <menucheckbox text="Item 4" selected="true" />
                <menucheckbox text="Item 5" />
                <menucheckbox text="Item 6" selected="true" />
                <menuseparator />
                <menuoptionbox text="Item 7" />
                <menuoptionbox text="Item 8" />
                <menuoptionbox text="Item 9" selected="true" />
                <menuseparator />
                <menuoptionbox text="Item 10" group="somegroup" />
                <menuoptionbox text="Item 11" group="somegroup" selected="true" />
                <menuoptionbox text="Item 12" group="somegroup" />
            </menu>
            <menuitem text="Item 3" shortcutText="Ctrl+B" />
            <menuitem text="Item 4" shortcutText="Ctrl+C" />
            <menuseparator />
            <menuitem text="Item 5" shortcutText="Ctrl+D" />
        </menu>
      </menubar>
    </vbox>
ianharrigan commented 5 months ago

i think on native systems the menu would close if you click a checkbox, no? Pretty sure that how it is on windows - not saying thats the "gold standard" in UI (far from it), but just trying to understand what "normal" expections might be

Shallowmallow commented 5 months ago

Humm, you're maybe right in fact. It's the behaviour of inkscape which is GTK. Oh, don't like it at all, but it seems to be the standard.

ianharrigan commented 5 months ago

I think im "with" the "normal" behaviour... if i have a checkbox in a menu (say "enable debug") when i check it, i wouldnt want to then also have to click off, or click the menu to close it... i would expect the option to be selected, the menu to close by itself and "debug to be enabled"... When i open the menu again, i would expect the checkbox to be checked

ianharrigan commented 5 months ago

in fact, looking at VSCode menus, it works exactly the same (say "View" -> "Appearance" -> anything with a checkmark), if the menu stayed there after i clicked it, it would feel very strange to me, like something broke.

Shallowmallow commented 5 months ago

in fact, looking at VSCode menus, it works exactly the same (say "View" -> "Appearance" -> anything with a checkmark), if the menu stayed there after i clicked it, it would feel very strange to me, like something broke.

Funny, I have the inverse reaction. The menu closes, without me seeing the checkbox being checked. So I feel like there's a bug, like the menu closed before the checkbox was checked, etc. So feel the need to click the menu a second time just to check if it was done right.

Shallowmallow commented 5 months ago

uievent BEFORE_CLOSE was implemented instead