mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-29 20:07:38 +00:00
Various updates to get keyboard equivalents for buttons working (especially
for panels). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3461 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
dd6cce428b
commit
9b25f83278
7 changed files with 357 additions and 233 deletions
|
@ -263,32 +263,62 @@ id gnustep_gui_nsbutton_class = nil;
|
|||
//
|
||||
// Setting the Key Equivalent
|
||||
//
|
||||
- (NSString *)keyEquivalent
|
||||
- (NSString*) keyEquivalent
|
||||
{
|
||||
return nil;
|
||||
return [cell keyEquivalent];
|
||||
}
|
||||
|
||||
- (unsigned int)keyEquivalentModifierMask
|
||||
- (unsigned int) keyEquivalentModifierMask
|
||||
{
|
||||
return 0;
|
||||
return [cell keyEquivalentModifierMask];
|
||||
}
|
||||
|
||||
- (void)setKeyEquivalent:(NSString *)aKeyEquivalent
|
||||
{}
|
||||
- (void) setKeyEquivalent: (NSString*)aKeyEquivalent
|
||||
{
|
||||
[cell setKeyEquivalent: aKeyEquivalent];
|
||||
}
|
||||
|
||||
- (void)setKeyEquivalentModifierMask:(unsigned int)mask
|
||||
{}
|
||||
- (void) setKeyEquivalentModifierMask: (unsigned int)mask
|
||||
{
|
||||
[cell setKeyEquivalentModifierMask: mask];
|
||||
}
|
||||
|
||||
//
|
||||
// Handling Events and Action Messages
|
||||
//
|
||||
- (void)performClick:(id)sender
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
[cell performClick:sender];
|
||||
return [self keyEquivalent] != nil;;
|
||||
}
|
||||
|
||||
- (BOOL)performKeyEquivalent:(NSEvent *)anEvent
|
||||
- (void) keyDown: (NSEvent*)theEvent
|
||||
{
|
||||
if ([self performKeyEquivalent: theEvent] == NO)
|
||||
[super keyDown: theEvent];
|
||||
}
|
||||
|
||||
- (void) performClick: (id)sender
|
||||
{
|
||||
[cell performClick: sender];
|
||||
}
|
||||
|
||||
- (BOOL) performKeyEquivalent: (NSEvent *)anEvent
|
||||
{
|
||||
if ([self isEnabled])
|
||||
{
|
||||
NSString *key = [self keyEquivalent];
|
||||
|
||||
if (key != nil && [key isEqual: [anEvent charactersIgnoringModifiers]])
|
||||
{
|
||||
unsigned int mask = [self keyEquivalentModifierMask];
|
||||
|
||||
if (([anEvent modifierFlags] & mask) == mask)
|
||||
{
|
||||
[self performClick: self];
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue