mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-15 20:42:40 +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;
|
get_base(this)->was_clicked = false;
|
||||||
|
|
||||||
// Check for ALT+some letter in menubar and some letter in menuboxes
|
// Check for ALT+some underlined letter
|
||||||
if (((this->type == JI_MENUBOX) && (!msg->any.shifts)) ||
|
if (((this->type == JI_MENUBOX) && (msg->any.shifts == 0 || // Inside menu-boxes we can use letters without Alt modifier pressed
|
||||||
((this->type == JI_MENUBAR) && (msg->any.shifts & KB_ALT_FLAG))) {
|
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));
|
selected = check_for_letter(menu, scancode_to_ascii(msg->key.scancode));
|
||||||
if (selected) {
|
if (selected) {
|
||||||
menu->highlightItem(selected, true, true, true);
|
menu->highlightItem(selected, true, true, true);
|
||||||
@ -503,17 +504,14 @@ bool MenuBox::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
if (!highlight && child_with_submenu_opened)
|
if (!highlight && child_with_submenu_opened)
|
||||||
highlight = child_with_submenu_opened;
|
highlight = child_with_submenu_opened;
|
||||||
|
|
||||||
switch (msg->key.scancode) {
|
switch (msg->key.scancode) {
|
||||||
|
|
||||||
case KEY_ESC:
|
case KEY_ESC:
|
||||||
/* in menu-bar */
|
/* in menu-bar */
|
||||||
if (this->type == JI_MENUBAR) {
|
if (this->type == JI_MENUBAR) {
|
||||||
if (highlight) {
|
if (highlight) {
|
||||||
menu->closeAll();
|
cancelMenuLoop();
|
||||||
|
|
||||||
/* fetch the focus */
|
|
||||||
jmanager_free_focus();
|
|
||||||
used = true;
|
used = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -632,7 +630,14 @@ bool MenuBox::onProcessMessage(Message* msg)
|
|||||||
break;
|
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;
|
break;
|
||||||
@ -1192,6 +1197,16 @@ void MenuBox::closePopup()
|
|||||||
jmanager_enqueue_message(msg);
|
jmanager_enqueue_message(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuBox::cancelMenuLoop()
|
||||||
|
{
|
||||||
|
Menu* menu = getMenu();
|
||||||
|
if (menu)
|
||||||
|
menu->closeAll();
|
||||||
|
|
||||||
|
// Lost focus
|
||||||
|
jmanager_free_focus();
|
||||||
|
}
|
||||||
|
|
||||||
void MenuItem::executeClick()
|
void MenuItem::executeClick()
|
||||||
{
|
{
|
||||||
// Send the message
|
// Send the message
|
||||||
|
@ -62,6 +62,10 @@ public:
|
|||||||
return m_base;
|
return m_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Closes all menu-boxes and goes back to the normal state of the
|
||||||
|
// menu-bar.
|
||||||
|
void cancelMenuLoop();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool onProcessMessage(Message* msg) OVERRIDE;
|
virtual bool onProcessMessage(Message* msg) OVERRIDE;
|
||||||
MenuBaseData* createBase();
|
MenuBaseData* createBase();
|
||||||
|
@ -1134,6 +1134,9 @@ static bool manager_msg_proc(JWidget widget, Message* msg)
|
|||||||
Shortcut* shortcut = *it;
|
Shortcut* shortcut = *it;
|
||||||
|
|
||||||
if (shortcut->is_pressed(msg)) {
|
if (shortcut->is_pressed(msg)) {
|
||||||
|
// Cancel menu-bar loops (to close any popup menu)
|
||||||
|
app_get_menubar()->cancelMenuLoop();
|
||||||
|
|
||||||
switch (shortcut->type) {
|
switch (shortcut->type) {
|
||||||
|
|
||||||
case Shortcut_ChangeTool: {
|
case Shortcut_ChangeTool: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user