mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 18:30:56 +00:00
Bug fixing; rewritten handling of cursor.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5438 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0e76deeaa6
commit
8a247703a8
1 changed files with 39 additions and 23 deletions
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <gnustep/gui/config.h>
|
#include <gnustep/gui/config.h>
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#include <AppKit/NSMenu.h>
|
||||||
#include <AppKit/NSPopUpButton.h>
|
#include <AppKit/NSPopUpButton.h>
|
||||||
#include <AppKit/NSPopUpButtonCell.h>
|
#include <AppKit/NSPopUpButtonCell.h>
|
||||||
#include <AppKit/NSApplication.h>
|
#include <AppKit/NSApplication.h>
|
||||||
|
@ -88,14 +89,8 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
- (id) initWithFrame: (NSRect)frameRect
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
pullsDown: (BOOL)flag
|
pullsDown: (BOOL)flag
|
||||||
{
|
{
|
||||||
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
|
|
||||||
|
|
||||||
[super initWithFrame: frameRect];
|
[super initWithFrame: frameRect];
|
||||||
|
[self setPullsDown: flag];
|
||||||
[defaultCenter addObserver: self
|
|
||||||
selector: @selector(_popup:)
|
|
||||||
name: NSPopUpButtonWillPopUpNotification
|
|
||||||
object: self];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +134,7 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
|
|
||||||
- (void) addItemsWithTitles: (NSArray *)itemTitles
|
- (void) addItemsWithTitles: (NSArray *)itemTitles
|
||||||
{
|
{
|
||||||
[cell addItemWithTitles: itemTitles];
|
[cell addItemsWithTitles: itemTitles];
|
||||||
|
|
||||||
[self synchronizeTitleAndSelectedItem];
|
[self synchronizeTitleAndSelectedItem];
|
||||||
}
|
}
|
||||||
|
@ -147,7 +142,8 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
- (void) insertItemWithTitle: (NSString *)title
|
- (void) insertItemWithTitle: (NSString *)title
|
||||||
atIndex: (int)index
|
atIndex: (int)index
|
||||||
{
|
{
|
||||||
[cell insertItemWithTitle: title adIndex: index];
|
[cell insertItemWithTitle: title
|
||||||
|
atIndex: index];
|
||||||
|
|
||||||
[self synchronizeTitleAndSelectedItem];
|
[self synchronizeTitleAndSelectedItem];
|
||||||
}
|
}
|
||||||
|
@ -161,7 +157,7 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
|
|
||||||
- (void) removeItemWithTitle: (NSString *)title
|
- (void) removeItemWithTitle: (NSString *)title
|
||||||
{
|
{
|
||||||
[cell removeItemWithTitle];
|
[cell removeItemWithTitle: title];
|
||||||
|
|
||||||
[self synchronizeTitleAndSelectedItem];
|
[self synchronizeTitleAndSelectedItem];
|
||||||
}
|
}
|
||||||
|
@ -190,7 +186,7 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
|
|
||||||
- (void) selectItem: (id <NSMenuItem>)anObject
|
- (void) selectItem: (id <NSMenuItem>)anObject
|
||||||
{
|
{
|
||||||
[cell selectedItem: anObject];
|
[cell selectItem: anObject];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) selectItemAtIndex: (int)index
|
- (void) selectItemAtIndex: (int)index
|
||||||
|
@ -245,6 +241,7 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
|
|
||||||
- (int) indexOfItemWithTag: (int)tag
|
- (int) indexOfItemWithTag: (int)tag
|
||||||
{
|
{
|
||||||
|
// FIXME: This clashes with an ivar!!
|
||||||
return [cell indexOfItemWithTag: tag];
|
return [cell indexOfItemWithTag: tag];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,20 +292,38 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
[[popb_menu menuRepresentation] sizeToFit];
|
[[popb_menu menuRepresentation] sizeToFit];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _popup: (NSNotification*)notification
|
|
||||||
{
|
|
||||||
[cell performClickWithFrame: [[notification object] frame]
|
|
||||||
inView: self];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) mouseDown: (NSEvent *)theEvent
|
- (void) mouseDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc;
|
NSMenuView *mr = [[cell menu] menuRepresentation];
|
||||||
|
NSEvent *e;
|
||||||
|
|
||||||
nc = [NSNotificationCenter defaultCenter];
|
if ([self isEnabled] == NO)
|
||||||
[nc postNotificationName: NSPopUpButtonWillPopUpNotification
|
return;
|
||||||
object: self
|
|
||||||
userInfo: nil];
|
// Attach the popUp
|
||||||
|
[cell attachPopUpWithFrame: bounds
|
||||||
|
inView: self];
|
||||||
|
|
||||||
|
// Process events; we start menu events processing by converting
|
||||||
|
// this event to the menu window, and sending it there.
|
||||||
|
e = [NSEvent mouseEventWithType: [theEvent type]
|
||||||
|
location: [[mr window] convertScreenToBase:
|
||||||
|
[window convertBaseToScreen:
|
||||||
|
[theEvent locationInWindow]]]
|
||||||
|
modifierFlags: [theEvent modifierFlags]
|
||||||
|
timestamp: [theEvent timestamp]
|
||||||
|
windowNumber: [[mr window] windowNumber]
|
||||||
|
context: nil // TODO ?
|
||||||
|
eventNumber: [theEvent eventNumber]
|
||||||
|
clickCount: [theEvent clickCount]
|
||||||
|
pressure: [theEvent pressure]];
|
||||||
|
[[mr window] sendEvent: e];
|
||||||
|
|
||||||
|
// Update our selected item
|
||||||
|
[self synchronizeTitleAndSelectedItem];
|
||||||
|
|
||||||
|
// Dismiss the popUp
|
||||||
|
[cell dismissPopUp];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -342,4 +357,5 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
*/
|
*/
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue