Interface Kit: Add support for shortcuts w/o Command
Introduce B_NO_COMMAND_KEY modifier that is used when a shortcut has no Command modifier, otherwise B_COMMAND_KEY modifier is added. This is conceptually different from B_NO_MODIFIERS in that it allows other modifiers such as B_CONTROL_KEY, B_SHIFT_KEY and B_OPTION_KEY to be added to a shortcut, but not B_COMMAND_KEY. This option is required to remove B_COMMAND_KEY because the Command modifier is assumed to be present on all shortcuts. This allows us to break this assumption without breaking apps written before this change and assume B_COMMAND_KEY to be present even if it has not been explictly added. Document B_NO_COMMAND_KEY in BMenuItem and BWindow docs. Fixes #7078 Co-authored-by: X512 <[email protected]> Co-authored-by: Ryan Leavengood <[email protected]> Change-Id: If0e20cd848112898f4425ede8c17231dc50deb8a Reviewed-on: https://review.haiku-os.org/c/haiku/+/7293 Tested-by: Commit checker robot <[email protected]> Reviewed-by: nephele nephele <[email protected]>
This commit is contained in:
co-authored by
X512
Ryan Leavengood
parent
a5f92820b7
commit
1e2091ced5
@@ -165,7 +165,8 @@ enum {
|
||||
B_LEFT_CONTROL_KEY = 0x00001000,
|
||||
B_RIGHT_CONTROL_KEY = 0x00002000,
|
||||
B_LEFT_OPTION_KEY = 0x00004000,
|
||||
B_RIGHT_OPTION_KEY = 0x00008000
|
||||
B_RIGHT_OPTION_KEY = 0x00008000,
|
||||
B_NO_COMMAND_KEY = 0x00010000
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2006-2025 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _MENU_ITEM_H
|
||||
@@ -23,8 +23,7 @@ class BMenuItem : public BArchivable, public BInvoker {
|
||||
public:
|
||||
BMenuItem(const char* label, BMessage* message,
|
||||
char shortcut = 0, uint32 modifiers = 0);
|
||||
BMenuItem(BMenu* menu,
|
||||
BMessage* message = NULL);
|
||||
BMenuItem(BMenu* menu, BMessage* message = NULL);
|
||||
BMenuItem(BMessage* data);
|
||||
virtual ~BMenuItem();
|
||||
|
||||
@@ -94,6 +93,7 @@ private:
|
||||
void _DrawShortcutSymbol(bool);
|
||||
void _DrawSubmenuSymbol();
|
||||
void _DrawControlChar(char shortcut, BPoint where);
|
||||
void _DrawFunctionChar(uint32 rawKey, BPoint where);
|
||||
|
||||
private:
|
||||
char* fLabel;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2015, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2001-2025 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _WINDOW_H
|
||||
@@ -316,7 +316,7 @@ private:
|
||||
BPoint AlertPosition(const BRect& frame);
|
||||
virtual BMessage* ConvertToMessage(void* raw, int32 code);
|
||||
|
||||
void AddShortcut(uint32 key, uint32 modifiers,
|
||||
void _AddShortcut(uint32 key, uint32 modifiers,
|
||||
BMenuItem* item);
|
||||
BHandler* _DetermineTarget(BMessage* message,
|
||||
BHandler* target);
|
||||
|
||||
Reference in New Issue
Block a user