Fixed bug #12680 and further clean up of NSPopupButtonCell.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@21122 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2005-04-17 21:25:32 +00:00
parent afe71bc4c7
commit 7084ee0b3b
3 changed files with 43 additions and 61 deletions

View file

@ -335,22 +335,10 @@ this to return nil to indicate that we have no context menu.
untilMouseUp: YES];
}
/* 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
{
// FIXME: This method also handles the key events for the popup menu window,
// as menu windows cannot become key window.
if ([self isEnabled])
{
NSString *characters = [theEvent characters];
@ -381,26 +369,17 @@ this to return nil to indicate that we have no context menu.
menuView = [[_cell menu] menuRepresentation];
if ([[menuView window] isVisible] == NO)
{
// Attach the popUp
[_cell attachPopUpWithFrame: _bounds
inView: self];
selectedIndex = [self indexOfSelectedItem];
if (selectedIndex > -1)
[menuView setHighlightedItemIndex: selectedIndex];
}
else
{
selectedIndex = [menuView highlightedItemIndex];
[[_cell menu] performActionForItemAtIndex: selectedIndex];
// Dismiss the popUp
[_cell dismissPopUp];
// Update our selected item
[self synchronizeTitleAndSelectedItem];
if (selectedIndex > 0)
{
[[_cell menu] performActionForItemAtIndex: selectedIndex];
}
}
}
return;