Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys
Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys
- Subject: Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys
- From: Eric Gorr <email@hidden>
- Date: Mon, 19 Jan 2009 10:40:50 -0500
On Jan 16, 2009, at 5:12 PM, Corbin Dunn wrote:
On Jan 16, 2009, at 11:34 AM, Eric Gorr wrote:
Note that for my custom cell class I have:
+ (BOOL)prefersTrackingUntilMouseUp {
// NSCell returns NO for this by default.
// If you want to have trackMouse:inRect:ofView:untilMouseUp:
// always track until the mouse is up, then you MUST return YES.
// Otherwise, strange things will happen.
return YES;
}
This is what tableview passes to untilMouseUp: in trackMouse:..
which I need for normal mouse clicks when when shift or cmd key is
not down. But I am not sure if this would be the cause of the
problem or not...just something to note for the moment.
What I think is happening is that when I call [super
mouseDown:theEvent], it consumes the mouseUp event. As such, when
my custom tracking occurs, there is no mouseUp event for it to
process.
While I might be able to place the call to [super
mouseDown:theEvent] below my custom tracking code, it is unclear
this would work as [super mouseDown:theEvent] needs an equal chance
to process events and my trackMouse code can consume events and not
tell anyone, when the shift or cmd key is pressed, that [super
mouseDown:theEvent] needs to know about to execute correctly.
You are right -- super is consuming the mouse up. I think you'll
have to call it later.
Unfortunately, calling it after my custom tracking code doesn't appear
to work out-of-the-box.
The problem appears to be that my trackMouse code consumes the mouseUp
event and that is preventing [super mouseDown:theEvent] from
terminating.
One possible solution is to add a method to my custom cell class to
set a flag which tells the trackMouse method that it was being called
due to the shift or cmd key being held down. And, when this is the
case, I don't dequeue the mouseUP event...calling NSApp's
nextEventMatchingMask instead of NSWindow's, which was originally
suggested.
theEvent = [NSApp nextEventMatchingMask:(NSLeftMouseUpMask |
NSLeftMouseDraggedMask | NSMouseEnteredMask | NSMouseExitedMask)
untilDate:[NSDate
dateWithTimeIntervalSinceNow:20]
inMode:NSEventTrackingRunLoopMode
dequeue:shouldDequeue];
This seems a bit hackish and am thinking there would be a better
solution.
The disadvantage is that you'll have to handle selection yourself,
which can be difficult with anchored selections.
Well, I knew I was going to handle selection myself since I need
entirely custom selection and I've written such code before, so I'm
not concerned about that.
Maybe you can just override the left/right arrows to do sub-
selection in your cell. For instance, image results in Tiger's
Spotlight help results did this. It didn't allow alt/cmd multi-select.
Unfortunately, I must implement the standard shift & cmd selection
functionality.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >Custom tracking in a NSTextFieldCell (From: Eric Gorr <email@hidden>) |
| >Re: Custom tracking in a NSTextFieldCell (From: Eric Gorr <email@hidden>) |
| >NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys (From: Eric Gorr <email@hidden>) |
| >Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys (From: Eric Gorr <email@hidden>) |
| >Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys (From: Corbin Dunn <email@hidden>) |
| >Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys (From: Eric Gorr <email@hidden>) |
| >Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys (From: Corbin Dunn <email@hidden>) |
| >Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys (From: Eric Gorr <email@hidden>) |
| >Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys (From: Eric Gorr <email@hidden>) |
| >Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys (From: Corbin Dunn <email@hidden>) |