When adding new multi-stroke keybindings with the same prefix, don't discard

the old ones


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12868 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2002-02-28 01:32:40 +00:00
parent 00e9132ee6
commit 06c06638a6

View file

@ -48,6 +48,7 @@
int modifiers;
GSKeyBindingAction *a = nil;
GSKeyBindingTable *t = nil;
BOOL isTable = NO;
int i;
if (![NSInputManager parseKey: key
@ -102,9 +103,11 @@
}
else if ([action isKindOfClass: [NSDictionary class]])
{
t = [[GSKeyBindingTable alloc] init];
[t loadBindingsFromDictionary: (NSDictionary *)action];
AUTORELEASE (t);
/* Don't load the keybindings from action yet ... load them
later on when we know if we need to create a new
GSKeyBindingTable or if we need to merge them into an
existing one. */
isTable = YES;
}
else if ([action isKindOfClass: [GSKeyBindingAction class]])
{
@ -120,15 +123,41 @@
if ((_bindings[i].character == character)
&& (_bindings[i].modifiers == modifiers))
{
/* Replace/override the existing action/table with the new
ones. */
/* Replace/override the existing action with the new one if
it's an action, or load the bindings into a (new or
existing) table if it's a table. */
if (isTable)
{
/* If there was already a table, add keybindings to that
table. */
if (_bindings[i].table != nil)
{
t = _bindings[i].table;
}
else
{
/* Else, create a new one. */
t = [[GSKeyBindingTable alloc] init];
AUTORELEASE (t);
}
[t loadBindingsFromDictionary: (NSDictionary *)action];
}
ASSIGN (_bindings[i].action, a);
ASSIGN (_bindings[i].table, t);
return;
}
}
/* Ok - allocate memory for the new binding. */
/* Ok - new keystroke. Create the table if needed. */
if (isTable)
{
t = [[GSKeyBindingTable alloc] init];
AUTORELEASE (t);
[t loadBindingsFromDictionary: (NSDictionary *)action];
}
/* Allocate memory for the new binding. */
if (_bindingsCount == 0)
{
_bindingsCount = 1;