mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:10:47 +00:00
Fixed combo box bug introduced in June
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19870 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
706921d435
commit
fb46ffd94f
3 changed files with 88 additions and 40 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2004-08-13 Quentin Mathe <qmathe@club-internet.fr>
|
||||||
|
|
||||||
|
* Source/NSComboBoxCell.m:
|
||||||
|
* Source/NSComboBox.m:
|
||||||
|
Fixed broken combo box behavior introduced June 17 with version 1.27,
|
||||||
|
which produced wrong tracking in the button cell and extra mouse down
|
||||||
|
call in the NSComboBox superclass. Now the rewritten version is also
|
||||||
|
documented.
|
||||||
|
Also now -[GSComboWindow deselectItemAtIndex:] still produces a
|
||||||
|
-[GSComboWindow tableViewSelectionDidChange:] call but the chain is
|
||||||
|
stopped in -[GSComboWindow validateSelection] by the _locationSelection
|
||||||
|
variable, then -[NSComboBoxCell selectItemAtIndex:] is not anymore
|
||||||
|
wrongly called.
|
||||||
|
|
||||||
2004-08-12 01:42 Alexander Malmberg <alexander@malmberg.org>
|
2004-08-12 01:42 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
* Source/NSLayoutManager.m
|
* Source/NSLayoutManager.m
|
||||||
|
|
|
@ -455,14 +455,14 @@ static NSNotificationCenter *nc;
|
||||||
// Overridden
|
// Overridden
|
||||||
- (void) mouseDown: (NSEvent*)theEvent
|
- (void) mouseDown: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
BOOL clicked;
|
BOOL buttonClicked;
|
||||||
// clicked is set to the value YES when the click occurs in the text cell
|
// buttonClicked is set to the value YNO when the click occurs in the text cell
|
||||||
// and to the value NO when it occurs in the button cell
|
// and to the value YES when it occurs in the button cell
|
||||||
|
|
||||||
clicked = [_cell trackMouse: theEvent inRect: [self bounds]
|
buttonClicked = [_cell trackMouse: theEvent inRect: [self bounds]
|
||||||
ofView: self untilMouseUp: YES];
|
ofView: self untilMouseUp: YES];
|
||||||
|
|
||||||
if (clicked)
|
if (!buttonClicked)
|
||||||
[super mouseDown: theEvent];
|
[super mouseDown: theEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -406,9 +406,7 @@ static GSComboWindow *gsWindow = nil;
|
||||||
[self makeFirstResponder: _tableView];
|
[self makeFirstResponder: _tableView];
|
||||||
[self runLoopWithComboBoxCell: comboBoxCell];
|
[self runLoopWithComboBoxCell: comboBoxCell];
|
||||||
|
|
||||||
[nc removeObserver: self];
|
[nc removeObserver: self name: nil object: onWindow];
|
||||||
[_tableView setDelegate: self];
|
|
||||||
// HACK: Need to reset the delegate to receive the next notifications
|
|
||||||
|
|
||||||
[self close];
|
[self close];
|
||||||
|
|
||||||
|
@ -562,7 +560,9 @@ static GSComboWindow *gsWindow = nil;
|
||||||
{
|
{
|
||||||
if (!ForceBrowser)
|
if (!ForceBrowser)
|
||||||
{
|
{
|
||||||
|
_localSelection = YES;
|
||||||
[_tableView deselectAll: self];
|
[_tableView deselectAll: self];
|
||||||
|
_localSelection = NO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1431,16 +1431,26 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Overrides NSCell <code>trackMouse:inRect:ofView:untilMouseUp:</code> method to establish a
|
||||||
|
* new method behavior.
|
||||||
|
* In the case <var>flag</var> is NO, returns NO when the mouse down occurs in the text
|
||||||
|
* cell part or when the mouse down occurs in the button cell part followed by a
|
||||||
|
* mouse up outside, otherwise returns YES (when both the mouse down and the
|
||||||
|
* mouse up occurs in the button cell part).
|
||||||
|
* In the case <var>flag</var> is YES, returns NO when the mouse occurs in the text
|
||||||
|
* cell part, otherwise returns YES (when the mouse down occurs in the button cell
|
||||||
|
* part).
|
||||||
|
*/
|
||||||
- (BOOL) trackMouse: (NSEvent *)theEvent
|
- (BOOL) trackMouse: (NSEvent *)theEvent
|
||||||
inRect: (NSRect)cellFrame
|
inRect: (NSRect)cellFrame
|
||||||
ofView: (NSView *)controlView
|
ofView: (NSView *)controlView
|
||||||
untilMouseUp: (BOOL)flag
|
untilMouseUp: (BOOL)flag
|
||||||
{
|
{
|
||||||
NSWindow *cvWindow = [controlView window];
|
|
||||||
NSPoint point;
|
NSPoint point;
|
||||||
BOOL isFlipped = [controlView isFlipped];
|
BOOL isFlipped = [controlView isFlipped];
|
||||||
BOOL clicked = NO;
|
|
||||||
NSRect buttonRect = buttonCellFrameFromRect(cellFrame);
|
NSRect buttonRect = buttonCellFrameFromRect(cellFrame);
|
||||||
|
NSRect textRect = textCellFrameFromRect(cellFrame);
|
||||||
|
BOOL result = NO;
|
||||||
|
|
||||||
// Should this be set by NSActionCell ?
|
// Should this be set by NSActionCell ?
|
||||||
if (_control_view != controlView)
|
if (_control_view != controlView)
|
||||||
|
@ -1451,38 +1461,62 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
|
||||||
point = [controlView convertPoint: [theEvent locationInWindow]
|
point = [controlView convertPoint: [theEvent locationInWindow]
|
||||||
fromView: nil];
|
fromView: nil];
|
||||||
|
|
||||||
if (!NSMouseInRect(point, cellFrame, isFlipped))
|
if (NSMouseInRect(point, textRect, isFlipped))
|
||||||
return NO;
|
|
||||||
else if ([theEvent type] == NSLeftMouseDown)
|
|
||||||
{
|
{
|
||||||
if (NSMouseInRect(point, textCellFrameFromRect(cellFrame), isFlipped))
|
return NO;
|
||||||
{
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
else if (NSMouseInRect(point, buttonRect, isFlipped))
|
|
||||||
{
|
|
||||||
[controlView lockFocus];
|
|
||||||
[_buttonCell highlight: YES withFrame: buttonRect inView: controlView];
|
|
||||||
[controlView unlockFocus];
|
|
||||||
[cvWindow flushWindow];
|
|
||||||
|
|
||||||
clicked = [_buttonCell trackMouse: theEvent
|
|
||||||
inRect: buttonRect
|
|
||||||
ofView: controlView
|
|
||||||
untilMouseUp: NO];
|
|
||||||
|
|
||||||
/* The click will be send by the target/action we have set for the button cell. */
|
|
||||||
|
|
||||||
[controlView lockFocus];
|
|
||||||
[_buttonCell highlight: NO withFrame: buttonRect inView: controlView];
|
|
||||||
[controlView unlockFocus];
|
|
||||||
[cvWindow flushWindow];
|
|
||||||
|
|
||||||
return clicked;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (NSMouseInRect(point, buttonRect, isFlipped))
|
||||||
return NO;
|
{
|
||||||
|
NSEvent *e = theEvent;
|
||||||
|
BOOL isMouseUp = NO;
|
||||||
|
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||||
|
| NSMouseMovedMask | NSLeftMouseDraggedMask | NSOtherMouseDraggedMask
|
||||||
|
| NSRightMouseDraggedMask;
|
||||||
|
NSPoint location;
|
||||||
|
|
||||||
|
while (!isMouseUp) // Loop until mouse goes up
|
||||||
|
{
|
||||||
|
location = [controlView convertPoint: [e locationInWindow] fromView: nil];
|
||||||
|
|
||||||
|
// Ask the cell to track the mouse only when the mouse is within the cell
|
||||||
|
if (NSMouseInRect(location, buttonRect, isFlipped))
|
||||||
|
{
|
||||||
|
[_buttonCell setHighlighted: YES];
|
||||||
|
[controlView setNeedsDisplay: YES];
|
||||||
|
|
||||||
|
result = [_buttonCell trackMouse: e
|
||||||
|
inRect: buttonRect
|
||||||
|
ofView: controlView
|
||||||
|
untilMouseUp: [NSButtonCell prefersTrackingUntilMouseUp]];
|
||||||
|
isMouseUp = result;
|
||||||
|
|
||||||
|
[_buttonCell setHighlighted: NO];
|
||||||
|
[controlView setNeedsDisplay: YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isMouseUp)
|
||||||
|
{
|
||||||
|
e = [NSApp nextEventMatchingMask: eventMask
|
||||||
|
untilDate: nil
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
|
dequeue: YES];
|
||||||
|
|
||||||
|
if ([e type] == NSLeftMouseUp)
|
||||||
|
isMouseUp = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO; // Pathological case, normally never happen
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) resetCursorRect: (NSRect)cellFrame inView: (NSView *)controlView
|
- (void) resetCursorRect: (NSRect)cellFrame inView: (NSView *)controlView
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue