Check if alt is the command key on BMenu::AttachedToWindow instead of doing it for every BMenuItem::Draw()
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16847 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -257,7 +257,7 @@ virtual void _ReservedMenu6();
|
|||||||
BMessage *r, bool menu) const;
|
BMessage *r, bool menu) const;
|
||||||
|
|
||||||
static menu_info sMenuInfo;
|
static menu_info sMenuInfo;
|
||||||
static bool sSwapped;
|
static bool sAltAsCommandKey;
|
||||||
|
|
||||||
BMenuItem *fChosenItem;
|
BMenuItem *fChosenItem;
|
||||||
BList fItems;
|
BList fItems;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
menu_info BMenu::sMenuInfo;
|
menu_info BMenu::sMenuInfo;
|
||||||
|
bool BMenu::sAltAsCommandKey;
|
||||||
|
|
||||||
static property_info
|
static property_info
|
||||||
sPropList[] = {
|
sPropList[] = {
|
||||||
@@ -256,6 +256,15 @@ BMenu::AttachedToWindow()
|
|||||||
{
|
{
|
||||||
BView::AttachedToWindow();
|
BView::AttachedToWindow();
|
||||||
|
|
||||||
|
sAltAsCommandKey = true;
|
||||||
|
key_map *keys = NULL;
|
||||||
|
char *chars = NULL;
|
||||||
|
get_key_map(&keys, &chars);
|
||||||
|
if (keys == NULL || keys->left_command_key != 0x5d || keys->right_command_key != 0x5f)
|
||||||
|
sAltAsCommandKey = false;
|
||||||
|
free(chars);
|
||||||
|
free(keys);
|
||||||
|
|
||||||
if (AddDynamicItem(B_INITIAL_ADD)) {
|
if (AddDynamicItem(B_INITIAL_ADD)) {
|
||||||
do {
|
do {
|
||||||
if (!OkToProceed(NULL)) {
|
if (!OkToProceed(NULL)) {
|
||||||
|
|||||||
@@ -703,21 +703,11 @@ BMenuItem::DrawShortcutSymbol()
|
|||||||
|
|
||||||
where -= BPoint(20, 10);
|
where -= BPoint(20, 10);
|
||||||
|
|
||||||
// TODO: Do this in a better way
|
|
||||||
bool altAsCommandKey = true;
|
|
||||||
key_map *keys = NULL;
|
|
||||||
char *chars;
|
|
||||||
get_key_map(&keys, &chars);
|
|
||||||
if (keys == NULL || keys->left_command_key != 0x5d || keys->right_command_key != 0x5f)
|
|
||||||
altAsCommandKey = false;
|
|
||||||
free(chars);
|
|
||||||
free(keys);
|
|
||||||
|
|
||||||
if (fModifiers & B_COMMAND_KEY) {
|
if (fModifiers & B_COMMAND_KEY) {
|
||||||
BRect rect(0,0,16,10);
|
BRect rect(0,0,16,10);
|
||||||
BBitmap control(rect, B_COLOR_8_BIT);
|
BBitmap control(rect, B_COLOR_8_BIT);
|
||||||
|
|
||||||
if (altAsCommandKey)
|
if (BMenu::sAltAsCommandKey)
|
||||||
control.SetBits(kAltBits, kAltLength, 0, B_COLOR_8_BIT);
|
control.SetBits(kAltBits, kAltLength, 0, B_COLOR_8_BIT);
|
||||||
else
|
else
|
||||||
control.SetBits(kCtrlBits, kCtrlLength, 0, B_COLOR_8_BIT);
|
control.SetBits(kCtrlBits, kCtrlLength, 0, B_COLOR_8_BIT);
|
||||||
@@ -730,7 +720,7 @@ BMenuItem::DrawShortcutSymbol()
|
|||||||
BRect rect(0,0,16,10);
|
BRect rect(0,0,16,10);
|
||||||
BBitmap control(rect, B_COLOR_8_BIT);
|
BBitmap control(rect, B_COLOR_8_BIT);
|
||||||
|
|
||||||
if (altAsCommandKey)
|
if (BMenu::sAltAsCommandKey)
|
||||||
control.SetBits(kCtrlBits, kCtrlLength, 0, B_COLOR_8_BIT);
|
control.SetBits(kCtrlBits, kCtrlLength, 0, B_COLOR_8_BIT);
|
||||||
else
|
else
|
||||||
control.SetBits(kAltBits, kAltLength, 0, B_COLOR_8_BIT);
|
control.SetBits(kAltBits, kAltLength, 0, B_COLOR_8_BIT);
|
||||||
|
|||||||
Reference in New Issue
Block a user