This commit is contained in:
Grim Maple 2023-05-19 19:45:11 +03:00
parent 663b7dfd73
commit e8f8282100
2 changed files with 18 additions and 12 deletions

View File

@ -421,6 +421,9 @@ class Window : CustomEventTarget {
signalWindow = true; signalWindow = true;
} }
if(newState == WindowState.minimized)
_popups.each!(x => x.close());
if (signalWindow && windowStateChanged.assigned) if (signalWindow && windowStateChanged.assigned)
windowStateChanged(this, newState, newWindowRect); windowStateChanged(this, newState, newWindowRect);
} }

View File

@ -619,14 +619,10 @@ class MenuWidgetBase : ListWidget {
// override in main menu // override in main menu
} }
protected void openSubmenu(int index, MenuItemWidget itemWidget, bool selectFirstItem) { protected void openSubmenu(int index, MenuItemWidget itemWidget) {
debug(DebugMenus) Log.d("menu", id, " open submenu ", index); debug(DebugMenus) Log.d("menu", id, " open submenu ", index);
if (_openedPopup !is null) { if (_openedPopup !is null) {
if (_openedPopupIndex == index) { if (_openedPopupIndex == index) {
if (selectFirstItem) {
window.setFocus(_openedMenu);
_openedMenu.selectItem(0);
}
return; return;
} else { } else {
_openedPopup.close(); _openedPopup.close();
@ -651,11 +647,11 @@ class MenuWidgetBase : ListWidget {
_openedMenu = popupMenu; _openedMenu = popupMenu;
_openedPopupIndex = index; _openedPopupIndex = index;
_selectedItemIndex = index; _selectedItemIndex = index;
if (selectFirstItem) { /*if (selectFirstItem) {
debug(DebugMenus) Log.d("menu: selecting first item"); debug(DebugMenus) Log.d("menu: selecting first item");
window.setFocus(popupMenu); window.setFocus(popupMenu);
_openedMenu.selectItem(0); _openedMenu.selectItem(-1);
} }*/
} }
enum MENU_OPEN_DELAY_MS = 400; enum MENU_OPEN_DELAY_MS = 400;
@ -683,7 +679,7 @@ class MenuWidgetBase : ListWidget {
if (itemWidget !is null) { if (itemWidget !is null) {
if (itemWidget.item.isSubmenu()) { if (itemWidget.item.isSubmenu()) {
Log.d("Opening submenu by timer"); Log.d("Opening submenu by timer");
openSubmenu(_submenuOpenItemIndex, itemWidget, _orientation == Orientation.Horizontal); // for main menu, select first item openSubmenu(_submenuOpenItemIndex, itemWidget);
} else { } else {
// normal item // normal item
} }
@ -723,7 +719,7 @@ class MenuWidgetBase : ListWidget {
if (_selectOnHover || popupWasOpen) { if (_selectOnHover || popupWasOpen) {
if (popupWasOpen && _orientation == Orientation.Horizontal) { if (popupWasOpen && _orientation == Orientation.Horizontal) {
// instantly open submenu in main menu if previous submenu was opened // instantly open submenu in main menu if previous submenu was opened
openSubmenu(index, itemWidget, false); // _orientation == Orientation.Horizontal for main menu, select first item openSubmenu(index, itemWidget);
} else { } else {
if (!isMainMenu) if (!isMainMenu)
scheduleOpenSubmenu(index); scheduleOpenSubmenu(index);
@ -817,7 +813,14 @@ class MenuWidgetBase : ListWidget {
//selectItem(-1); //selectItem(-1);
selectOnHover = false; selectOnHover = false;
} else { } else {
openSubmenu(index, itemWidget, _orientation == Orientation.Horizontal); // for main menu, select first item if(_openedPopupIndex == index)
{
_openedPopup.close();
_openedPopup = null;
_openedPopupIndex = -1;
}
else
openSubmenu(index, itemWidget);
selectOnHover = true; selectOnHover = true;
} }
} else { } else {
@ -882,7 +885,7 @@ class MenuWidgetBase : ListWidget {
} else if (event.keyCode == KeyCode.RIGHT) { } else if (event.keyCode == KeyCode.RIGHT) {
MenuItemWidget thisItem = selectedMenuItemWidget(); MenuItemWidget thisItem = selectedMenuItemWidget();
if (thisItem !is null && thisItem.item.isSubmenu) { if (thisItem !is null && thisItem.item.isSubmenu) {
openSubmenu(_selectedItemIndex, thisItem, true); openSubmenu(_selectedItemIndex, thisItem);
return true; return true;
} else if (_parentMenu !is null && _parentMenu.orientation == Orientation.Horizontal) { } else if (_parentMenu !is null && _parentMenu.orientation == Orientation.Horizontal) {
_parentMenu.moveSelection(1); _parentMenu.moveSelection(1);