Keymap: Add ability to remove a key mapping
... of a normal (non-modifier) key via a right click menu.
This commit is contained in:
@@ -215,11 +215,20 @@ KeyboardLayoutView::MouseDown(BPoint point)
|
||||
&& (modifiers() & B_CONTROL_KEY) != 0)) {
|
||||
// secondary mouse button, pop up a swap context menu
|
||||
if (!is_mappable_to_modifier(key->code)) {
|
||||
// ToDo: pop up a list of alternative characters
|
||||
fButtons = buttons;
|
||||
return;
|
||||
}
|
||||
|
||||
// ToDo: Pop up a list of alternative characters to map
|
||||
// the key to. Currently we only add an option to remove the
|
||||
// current key mapping.
|
||||
BPopUpMenu* alternativesPopUp = new BPopUpMenu(
|
||||
"Alternatives pop up", true, true, B_ITEMS_IN_COLUMN);
|
||||
BMessage* message = new BMessage(kMsgUpdateNormalKeys);
|
||||
message->AddUInt32("keyCode", key->code);
|
||||
message->AddBool("unset", true);
|
||||
alternativesPopUp->AddItem(new BMenuItem(B_TRANSLATE("Remove"),
|
||||
message));
|
||||
alternativesPopUp->SetAsyncAutoDestruct(true);
|
||||
if (alternativesPopUp->SetTargetForItems(Window()) == B_OK)
|
||||
alternativesPopUp->Go(ConvertToScreen(point), true);
|
||||
} else {
|
||||
// pop up the modifier keys menu
|
||||
BPopUpMenu* modifiersPopUp = new BPopUpMenu("Modifiers pop up",
|
||||
true, true, B_ITEMS_IN_COLUMN);
|
||||
@@ -321,6 +330,7 @@ KeyboardLayoutView::MouseDown(BPoint point)
|
||||
modifiersPopUp->SetAsyncAutoDestruct(true);
|
||||
if (modifiersPopUp->SetTargetForItems(Window()) == B_OK)
|
||||
modifiersPopUp->Go(ConvertToScreen(point), true);
|
||||
}
|
||||
} else if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0
|
||||
&& (fButtons & B_TERTIARY_MOUSE_BUTTON) == 0) {
|
||||
// tertiary mouse button, toggle the "deadness" of dead keys
|
||||
|
||||
@@ -374,7 +374,7 @@ Keymap::SetKey(uint32 keyCode, uint32 modifiers, int8 deadKey,
|
||||
if (offset < 0)
|
||||
return;
|
||||
|
||||
if (numBytes == -1)
|
||||
if (numBytes < 0)
|
||||
numBytes = strlen(bytes);
|
||||
if (numBytes > 6)
|
||||
return;
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
static const uint32 kMsgShowModifierKeysWindow = 'smkw';
|
||||
static const uint32 kMsgCloseModifierKeysWindow = 'hmkw';
|
||||
static const uint32 kMsgUpdateModifierKeys = 'umks';
|
||||
static const uint32 kMsgUpdateModifierKeys = 'umod';
|
||||
static const uint32 kMsgUpdateNormalKeys = 'ukey';
|
||||
|
||||
|
||||
class KeymapApplication : public BApplication {
|
||||
|
||||
@@ -320,6 +320,21 @@ KeymapWindow::MessageReceived(BMessage* message)
|
||||
_UpdateButtons();
|
||||
break;
|
||||
|
||||
case kMsgUpdateNormalKeys:
|
||||
{
|
||||
uint32 keyCode;
|
||||
if (message->FindUInt32("keyCode", &keyCode) != B_OK)
|
||||
break;
|
||||
|
||||
bool unset;
|
||||
if (message->FindBool("unset", &unset) == B_OK && unset) {
|
||||
fCurrentMap.SetKey(keyCode, modifiers(), 0, "", 0);
|
||||
_UpdateButtons();
|
||||
fKeyboardLayoutView->SetKeymap(&fCurrentMap);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgUpdateModifierKeys:
|
||||
{
|
||||
uint32 keyCode;
|
||||
|
||||
Reference in New Issue
Block a user