mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 21:50:46 +00:00
Simplified NSControls mouseDown: method.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23248 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1a6c6d9e03
commit
54219e0d9b
2 changed files with 35 additions and 49 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2006-08-10 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSControl.m (mouseDown:): Simplified code to no longer
|
||||||
|
fiddle with the cells action mask nor to capture the mouse.
|
||||||
|
|
||||||
2006-08-09 02:28-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
2006-08-09 02:28-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/NSButtonCell.m: Correct encoding of repeat and delay in
|
* Source/NSButtonCell.m: Correct encoding of repeat and delay in
|
||||||
|
|
|
@ -732,82 +732,63 @@ static Class actionCellClass;
|
||||||
*/
|
*/
|
||||||
- (void) mouseDown: (NSEvent *)theEvent
|
- (void) mouseDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSApplication *theApp = [NSApplication sharedApplication];
|
|
||||||
BOOL mouseUp = NO, done = NO;
|
|
||||||
NSEvent *e;
|
|
||||||
int oldActionMask;
|
|
||||||
NSPoint location;
|
|
||||||
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||||
| NSMouseMovedMask | NSLeftMouseDraggedMask | NSOtherMouseDraggedMask
|
| NSMouseMovedMask | NSLeftMouseDraggedMask | NSOtherMouseDraggedMask
|
||||||
| NSRightMouseDraggedMask;
|
| NSRightMouseDraggedMask;
|
||||||
|
BOOL mouseUp = NO;
|
||||||
|
|
||||||
|
// If not enabled ignore mouse clicks
|
||||||
if (![self isEnabled])
|
if (![self isEnabled])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Ignore multiple clicks, if configured to do so
|
||||||
if (_ignoresMultiClick && ([theEvent clickCount] > 1))
|
if (_ignoresMultiClick && ([theEvent clickCount] > 1))
|
||||||
{
|
{
|
||||||
[super mouseDown: theEvent];
|
[super mouseDown: theEvent];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([_cell isContinuous])
|
|
||||||
{
|
|
||||||
oldActionMask = [_cell sendActionOn: NSPeriodicMask];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
oldActionMask = [_cell sendActionOn: 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
[_window _captureMouse: self];
|
|
||||||
|
|
||||||
e = theEvent;
|
|
||||||
// loop until mouse goes up
|
// loop until mouse goes up
|
||||||
while (!done)
|
while (1)
|
||||||
{
|
{
|
||||||
location = [e locationInWindow];
|
NSPoint location = [self convertPoint: [theEvent locationInWindow]
|
||||||
location = [self convertPoint: location fromView: nil];
|
fromView: nil];
|
||||||
// ask the cell to track the mouse only
|
|
||||||
|
// ask the cell to track the mouse only,
|
||||||
// if the mouse is within the cell
|
// if the mouse is within the cell
|
||||||
if ([self mouse: location inRect: _bounds])
|
if ([self mouse: location inRect: _bounds])
|
||||||
{
|
{
|
||||||
|
BOOL done;
|
||||||
|
|
||||||
[_cell setHighlighted: YES];
|
[_cell setHighlighted: YES];
|
||||||
[self setNeedsDisplay: YES];
|
[self setNeedsDisplay: YES];
|
||||||
if ([_cell trackMouse: e
|
done = [_cell trackMouse: theEvent
|
||||||
inRect: _bounds
|
inRect: _bounds
|
||||||
ofView: self
|
ofView: self
|
||||||
untilMouseUp: [[_cell class] prefersTrackingUntilMouseUp]])
|
untilMouseUp: [[_cell class] prefersTrackingUntilMouseUp]];
|
||||||
done = mouseUp = YES;
|
[_cell setHighlighted: NO];
|
||||||
else
|
[self setNeedsDisplay: YES];
|
||||||
{
|
|
||||||
[_cell setHighlighted: NO];
|
if (done)
|
||||||
[self setNeedsDisplay: YES];
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (done)
|
theEvent = [NSApp nextEventMatchingMask: event_mask
|
||||||
break;
|
untilDate: nil
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
e = [theApp nextEventMatchingMask: event_mask
|
dequeue: YES];
|
||||||
untilDate: nil
|
if ([theEvent type] == NSLeftMouseUp)
|
||||||
inMode: NSEventTrackingRunLoopMode
|
{
|
||||||
dequeue: YES];
|
mouseUp = YES;
|
||||||
if ([e type] == NSLeftMouseUp)
|
break;
|
||||||
done = YES;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[_window _releaseMouse: self];
|
// Mouse went up inside the control but not inside the cell
|
||||||
|
|
||||||
if (mouseUp)
|
if (mouseUp)
|
||||||
{
|
{
|
||||||
[_cell setHighlighted: NO];
|
[self sendAction: [self action] to: [self target]];
|
||||||
[self setNeedsDisplay: YES];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[_cell sendActionOn: oldActionMask];
|
|
||||||
|
|
||||||
if (mouseUp)
|
|
||||||
[self sendAction: [self action] to: [self target]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent
|
- (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue