mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 16:21:56 +00:00
Handle key/mouse selections
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12083 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
facc374495
commit
ebdd056b94
2 changed files with 38 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2002-01-10 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSPopUpButton.m (-keyDown:): Handle obscure case of user
|
||||||
|
opening menu with key and selecting with mouse. Upon key selection,
|
||||||
|
get selected index from menuView highlightedItemIndex.
|
||||||
|
|
||||||
2002-01-10 Richard Frith-Macdonald <rfm@gnu.org>
|
2002-01-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSPasteboard.m: Improve handling of -NSHost user default
|
* Source/NSPasteboard.m: Improve handling of -NSHost user default
|
||||||
|
|
|
@ -339,6 +339,20 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
[self synchronizeTitleAndSelectedItem];
|
[self synchronizeTitleAndSelectedItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Private method which covers an obscure case where the user uses the
|
||||||
|
keyboard to open a popup, but subsequently uses the mouse to select
|
||||||
|
an item. We'll never know this was done (and thus cannot dismiss
|
||||||
|
the popUp) without getting this notification */
|
||||||
|
- (void) _handleNotification: (NSNotification*)aNotification
|
||||||
|
{
|
||||||
|
NSString *name = [aNotification name];
|
||||||
|
if ([name isEqual: NSMenuDidSendActionNotification] == YES)
|
||||||
|
{
|
||||||
|
[_cell dismissPopUp];
|
||||||
|
[self synchronizeTitleAndSelectedItem];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) keyDown: (NSEvent*)theEvent
|
- (void) keyDown: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
if ([self isEnabled])
|
if ([self isEnabled])
|
||||||
|
@ -358,26 +372,40 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
case NSCarriageReturnCharacter:
|
case NSCarriageReturnCharacter:
|
||||||
case ' ':
|
case ' ':
|
||||||
{
|
{
|
||||||
|
int selectedIndex;
|
||||||
NSMenuView *menuView;
|
NSMenuView *menuView;
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
menuView = [[_cell menu] menuRepresentation];
|
menuView = [[_cell menu] menuRepresentation];
|
||||||
if ([[menuView window] isVisible] == NO)
|
if ([[menuView window] isVisible] == NO)
|
||||||
{
|
{
|
||||||
int selectedIndex;
|
|
||||||
|
|
||||||
// Attach the popUp
|
// Attach the popUp
|
||||||
[_cell attachPopUpWithFrame: _bounds
|
[_cell attachPopUpWithFrame: _bounds
|
||||||
inView: self];
|
inView: self];
|
||||||
|
|
||||||
selectedIndex = [self indexOfSelectedItem];
|
|
||||||
|
|
||||||
|
selectedIndex = [self indexOfSelectedItem];
|
||||||
if (selectedIndex > -1)
|
if (selectedIndex > -1)
|
||||||
[menuView setHighlightedItemIndex: selectedIndex];
|
[menuView setHighlightedItemIndex: selectedIndex];
|
||||||
|
|
||||||
|
/* This covers an obscure case where the user subsequently
|
||||||
|
uses the mouse to select an item. We'll never know
|
||||||
|
this was done (and thus cannot dismiss the popUp) without
|
||||||
|
getting this notification */
|
||||||
|
[nc addObserver: self
|
||||||
|
selector: @selector(_handleNotification:)
|
||||||
|
name: NSMenuDidSendActionNotification
|
||||||
|
object: [_cell menu]];
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[[_cell menu] performActionForItemAtIndex:
|
[nc removeObserver: self
|
||||||
[self indexOfSelectedItem]];
|
name: NSMenuDidSendActionNotification
|
||||||
|
object: [_cell menu]];
|
||||||
|
selectedIndex = [menuView highlightedItemIndex];
|
||||||
|
[[_cell menu] performActionForItemAtIndex: selectedIndex];
|
||||||
|
|
||||||
// Dismiss the popUp
|
// Dismiss the popUp
|
||||||
[_cell dismissPopUp];
|
[_cell dismissPopUp];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue