mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 07:20:47 +00:00
Moved mouse interaction of popup button from control to cell.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20719 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f7892fd073
commit
f9a7c84e10
3 changed files with 73 additions and 61 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2005-02-14 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSPopupButton.m (-mouseDown:): Moved code from here ...
|
||||||
|
* Source/NSPopupButtonCell.m
|
||||||
|
(-trackMouse:inRect:ofView:untilMouseUp:): ... to here. This fixes
|
||||||
|
bug #9824.
|
||||||
|
|
||||||
2005-02-14 Richard Frith-Macdoanld <rfm@gnu.org>
|
2005-02-14 Richard Frith-Macdoanld <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSTitleView.m (-mouseDown:): Post an
|
* Source/GSTitleView.m (-mouseDown:): Post an
|
||||||
|
|
|
@ -329,67 +329,10 @@ this to return nil to indicate that we have no context menu.
|
||||||
|
|
||||||
- (void) mouseDown: (NSEvent*)theEvent
|
- (void) mouseDown: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
NSMenuView *mr = [[_cell menu] menuRepresentation];
|
[_cell trackMouse: theEvent
|
||||||
NSWindow *menuWindow = [mr window];
|
inRect: [self bounds]
|
||||||
NSEvent *e;
|
ofView: self
|
||||||
NSPoint p;
|
untilMouseUp: YES];
|
||||||
int lastSelectedItem = [_cell indexOfSelectedItem];
|
|
||||||
int highlightedItemIndex;
|
|
||||||
|
|
||||||
if ([self isEnabled] == NO)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ([[_cell menu] numberOfItems] == 0)
|
|
||||||
{
|
|
||||||
NSBeep ();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach the popUp
|
|
||||||
[_cell attachPopUpWithFrame: _bounds
|
|
||||||
inView: self];
|
|
||||||
|
|
||||||
p = [_window convertBaseToScreen: [theEvent locationInWindow]];
|
|
||||||
p = [menuWindow convertScreenToBase: p];
|
|
||||||
|
|
||||||
// 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: p
|
|
||||||
modifierFlags: [theEvent modifierFlags]
|
|
||||||
timestamp: [theEvent timestamp]
|
|
||||||
windowNumber: [menuWindow windowNumber]
|
|
||||||
context: [theEvent context]
|
|
||||||
eventNumber: [theEvent eventNumber]
|
|
||||||
clickCount: [theEvent clickCount]
|
|
||||||
pressure: [theEvent pressure]];
|
|
||||||
[NSApp sendEvent: e];
|
|
||||||
|
|
||||||
// Get highlighted item index from _cell because NSMenuView:
|
|
||||||
// - tells to NSPopUpButtonCell about current selected item index;
|
|
||||||
// - sets own selected item index to -1;
|
|
||||||
//
|
|
||||||
// So, at this point [mr highlightedItemIndex] always = -1
|
|
||||||
highlightedItemIndex = [_cell indexOfSelectedItem];
|
|
||||||
|
|
||||||
// Selection remains unchanged if selected item is disabled
|
|
||||||
// or mouse left menu (highlightedItemIndex == -1).
|
|
||||||
if ( highlightedItemIndex < 0
|
|
||||||
|| highlightedItemIndex == lastSelectedItem
|
|
||||||
|| [[self itemAtIndex: highlightedItemIndex] isEnabled] == NO)
|
|
||||||
{
|
|
||||||
[mr setHighlightedItemIndex: lastSelectedItem];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[mr setHighlightedItemIndex: highlightedItemIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dismiss the popUp
|
|
||||||
[_cell dismissPopUp];
|
|
||||||
|
|
||||||
// Update our selected item
|
|
||||||
[self synchronizeTitleAndSelectedItem];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Private method which covers an obscure case where the user uses the
|
/* Private method which covers an obscure case where the user uses the
|
||||||
|
|
|
@ -632,6 +632,68 @@ static NSImage *_pbc_image[2];
|
||||||
ofView: (NSView *)controlView
|
ofView: (NSView *)controlView
|
||||||
untilMouseUp: (BOOL)untilMouseUp
|
untilMouseUp: (BOOL)untilMouseUp
|
||||||
{
|
{
|
||||||
|
NSMenuView *mr = [[self menu] menuRepresentation];
|
||||||
|
NSWindow *menuWindow = [mr window];
|
||||||
|
NSEvent *e;
|
||||||
|
NSPoint p;
|
||||||
|
int lastSelectedItem = [self indexOfSelectedItem];
|
||||||
|
int highlightedItemIndex;
|
||||||
|
|
||||||
|
if ([self isEnabled] == NO)
|
||||||
|
return NO;
|
||||||
|
|
||||||
|
if ([[self menu] numberOfItems] == 0)
|
||||||
|
{
|
||||||
|
NSBeep ();
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach the popUp
|
||||||
|
[self attachPopUpWithFrame: cellFrame
|
||||||
|
inView: controlView];
|
||||||
|
|
||||||
|
p = [[controlView window] convertBaseToScreen: [theEvent locationInWindow]];
|
||||||
|
p = [menuWindow convertScreenToBase: p];
|
||||||
|
|
||||||
|
// 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: p
|
||||||
|
modifierFlags: [theEvent modifierFlags]
|
||||||
|
timestamp: [theEvent timestamp]
|
||||||
|
windowNumber: [menuWindow windowNumber]
|
||||||
|
context: [theEvent context]
|
||||||
|
eventNumber: [theEvent eventNumber]
|
||||||
|
clickCount: [theEvent clickCount]
|
||||||
|
pressure: [theEvent pressure]];
|
||||||
|
[NSApp sendEvent: e];
|
||||||
|
|
||||||
|
// Get highlighted item index from cell because NSMenuView:
|
||||||
|
// - tells to NSPopUpButtonCell about current selected item index;
|
||||||
|
// - sets own selected item index to -1;
|
||||||
|
//
|
||||||
|
// So, at this point [mr highlightedItemIndex] always = -1
|
||||||
|
highlightedItemIndex = [self indexOfSelectedItem];
|
||||||
|
|
||||||
|
// Selection remains unchanged if selected item is disabled
|
||||||
|
// or mouse left menu (highlightedItemIndex == -1).
|
||||||
|
if ( highlightedItemIndex < 0
|
||||||
|
|| highlightedItemIndex == lastSelectedItem
|
||||||
|
|| [[self itemAtIndex: highlightedItemIndex] isEnabled] == NO)
|
||||||
|
{
|
||||||
|
[mr setHighlightedItemIndex: lastSelectedItem];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[mr setHighlightedItemIndex: highlightedItemIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dismiss the popUp
|
||||||
|
[self dismissPopUp];
|
||||||
|
|
||||||
|
// Update our selected item
|
||||||
|
[self synchronizeTitleAndSelectedItem];
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue