mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-03 16:13:43 +00:00
Fix a bug introduced in aseprite 0.9.2, commit 8a1295c0250d1cbb7982220931262458b1ceed8c.
Widget::getMnemonicChar() can return 0, and we should pre-check this value before we compare the mnemonic with the pressed ascii char.
This commit is contained in:
parent
b090629897
commit
5da37e237b
@ -1211,7 +1211,8 @@ static MenuItem* check_for_letter(Menu* menu, int ascii)
|
||||
continue;
|
||||
|
||||
MenuItem* menuitem = static_cast<MenuItem*>(child);
|
||||
if (menuitem->getMnemonicChar() == tolower(ascii))
|
||||
int mnemonic = menuitem->getMnemonicChar();
|
||||
if (mnemonic > 0 && mnemonic == tolower(ascii))
|
||||
return menuitem;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -1200,10 +1200,9 @@ bool Widget::hasCapture()
|
||||
int Widget::getMnemonicChar() const
|
||||
{
|
||||
if (hasText()) {
|
||||
const char* text = getText();
|
||||
for (int c=0; text[c]; ++c)
|
||||
if ((text[c] == '&') && (text[c+1] != '&'))
|
||||
return tolower(text[c+1]);
|
||||
for (int c=0; m_text[c]; ++c)
|
||||
if ((m_text[c] == '&') && (m_text[c+1] != '&'))
|
||||
return tolower(m_text[c+1]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1218,7 +1217,8 @@ bool Widget::isScancodeMnemonic(int scancode) const
|
||||
else
|
||||
return false;
|
||||
|
||||
return (getMnemonicChar() == ascii);
|
||||
int mnemonic = getMnemonicChar();
|
||||
return (mnemonic > 0 && mnemonic == ascii);
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user