Menu: check numBytes == 1 on KeyDown
This commit is contained in:
@@ -268,6 +268,7 @@ private:
|
|||||||
|
|
||||||
int _State(BMenuItem** _item = NULL) const;
|
int _State(BMenuItem** _item = NULL) const;
|
||||||
void _InvokeItem(BMenuItem* item, bool now = false);
|
void _InvokeItem(BMenuItem* item, bool now = false);
|
||||||
|
void _InvokeTrigger(const char* bytes);
|
||||||
void _QuitTracking(bool onlyThis = true);
|
void _QuitTracking(bool onlyThis = true);
|
||||||
|
|
||||||
static menu_info sMenuInfo;
|
static menu_info sMenuInfo;
|
||||||
|
|||||||
+22
-13
@@ -476,6 +476,11 @@ BMenu::MessageReceived(BMessage* msg)
|
|||||||
void
|
void
|
||||||
BMenu::KeyDown(const char* bytes, int32 numBytes)
|
BMenu::KeyDown(const char* bytes, int32 numBytes)
|
||||||
{
|
{
|
||||||
|
if (numBytes != 1) {
|
||||||
|
_InvokeTrigger(bytes);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Test how it works on BeOS R5 and implement this correctly
|
// TODO: Test how it works on BeOS R5 and implement this correctly
|
||||||
switch (bytes[0]) {
|
switch (bytes[0]) {
|
||||||
case B_UP_ARROW:
|
case B_UP_ARROW:
|
||||||
@@ -574,19 +579,7 @@ BMenu::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
_InvokeTrigger(bytes);
|
||||||
uint32 trigger = UTF8ToCharCode(&bytes);
|
|
||||||
|
|
||||||
for (uint32 i = CountItems(); i-- > 0;) {
|
|
||||||
BMenuItem* item = ItemAt(i);
|
|
||||||
if (item->fTriggerIndex < 0 || item->fTrigger != trigger)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
_InvokeItem(item);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2467,6 +2460,22 @@ BMenu::_InvokeItem(BMenuItem* item, bool now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BMenu::_InvokeTrigger(const char* bytes)
|
||||||
|
{
|
||||||
|
uint32 trigger = UTF8ToCharCode(&bytes);
|
||||||
|
|
||||||
|
for (uint32 i = CountItems(); i-- > 0;) {
|
||||||
|
BMenuItem* item = ItemAt(i);
|
||||||
|
if (item->fTriggerIndex < 0 || item->fTrigger != trigger)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
_InvokeItem(item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BMenu::_OverSuper(BPoint location)
|
BMenu::_OverSuper(BPoint location)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user