mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-15 11:42:30 +00:00
Fix several menu glitches.
+ Fixed issue #10 (Alt+sequence of underlined letters is working now). + Close the whole menu hierarchy when Alt key is released and then pressed again. + Close all menus when a command is executed.
This commit is contained in:
parent
305a824d72
commit
132e246ebf
@ -474,9 +474,10 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
|
||||
get_base(this)->was_clicked = false;
|
||||
|
||||
// Check for ALT+some letter in menubar and some letter in menuboxes
|
||||
if (((this->type == JI_MENUBOX) && (!msg->any.shifts)) ||
|
||||
((this->type == JI_MENUBAR) && (msg->any.shifts & KB_ALT_FLAG))) {
|
||||
// Check for ALT+some underlined letter
|
||||
if (((this->type == JI_MENUBOX) && (msg->any.shifts == 0 || // Inside menu-boxes we can use letters without Alt modifier pressed
|
||||
msg->any.shifts == KB_ALT_FLAG)) ||
|
||||
((this->type == JI_MENUBAR) && (msg->any.shifts == KB_ALT_FLAG))) {
|
||||
selected = check_for_letter(menu, scancode_to_ascii(msg->key.scancode));
|
||||
if (selected) {
|
||||
menu->highlightItem(selected, true, true, true);
|
||||
@ -503,17 +504,14 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
|
||||
if (!highlight && child_with_submenu_opened)
|
||||
highlight = child_with_submenu_opened;
|
||||
|
||||
|
||||
switch (msg->key.scancode) {
|
||||
|
||||
case KEY_ESC:
|
||||
/* in menu-bar */
|
||||
if (this->type == JI_MENUBAR) {
|
||||
if (highlight) {
|
||||
menu->closeAll();
|
||||
|
||||
/* fetch the focus */
|
||||
jmanager_free_focus();
|
||||
cancelMenuLoop();
|
||||
used = true;
|
||||
}
|
||||
}
|
||||
@ -632,7 +630,14 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
break;
|
||||
}
|
||||
|
||||
return used;
|
||||
// Return true if we've already consumed the key.
|
||||
if (used) {
|
||||
return true;
|
||||
}
|
||||
// If the user presses the ALT key we close everything.
|
||||
else if (msg->key.scancode == KEY_ALT) {
|
||||
cancelMenuLoop();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1192,6 +1197,16 @@ void MenuBox::closePopup()
|
||||
jmanager_enqueue_message(msg);
|
||||
}
|
||||
|
||||
void MenuBox::cancelMenuLoop()
|
||||
{
|
||||
Menu* menu = getMenu();
|
||||
if (menu)
|
||||
menu->closeAll();
|
||||
|
||||
// Lost focus
|
||||
jmanager_free_focus();
|
||||
}
|
||||
|
||||
void MenuItem::executeClick()
|
||||
{
|
||||
// Send the message
|
||||
|
@ -62,6 +62,10 @@ public:
|
||||
return m_base;
|
||||
}
|
||||
|
||||
// Closes all menu-boxes and goes back to the normal state of the
|
||||
// menu-bar.
|
||||
void cancelMenuLoop();
|
||||
|
||||
protected:
|
||||
virtual bool onProcessMessage(Message* msg) OVERRIDE;
|
||||
MenuBaseData* createBase();
|
||||
|
@ -1134,6 +1134,9 @@ static bool manager_msg_proc(JWidget widget, Message* msg)
|
||||
Shortcut* shortcut = *it;
|
||||
|
||||
if (shortcut->is_pressed(msg)) {
|
||||
// Cancel menu-bar loops (to close any popup menu)
|
||||
app_get_menubar()->cancelMenuLoop();
|
||||
|
||||
switch (shortcut->type) {
|
||||
|
||||
case Shortcut_ChangeTool: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user