• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Catching NSSlider -mouseUp: events (workaround)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Catching NSSlider -mouseUp: events (workaround)


  • Subject: Re: Catching NSSlider -mouseUp: events (workaround)
  • From: Ron Fleckner <email@hidden>
  • Date: Fri, 13 Apr 2007 08:06:05 +1000


On 13/04/2007, at 7:51 AM, Roland Torres wrote:

On Apr 12, 2007, at 7:10 AM, Ron Fleckner wrote:

Roland Torres wrote:

Searching the archives, I couldn't find a solution to this problem:
Some controls (like NSSlider) have their own event loop established
in -mouseDown:, with the net effect that the -mouseUp: event is
caught and processed behind the scenes. The downside to this is that
if you override -mouseUp: with your own method, it won't get invoked.
Bummer if you want to key off of the mouseUp event to do something or
stop something in progress.


So, for the archives, here's the workaround I came up with for my
NSSlider subclass:

- (void)mouseDown:(NSEvent *)event
{
     [super mouseDown:event];   // eats the mouse-up event
     NSEvent upEvent=[NSEvent mouseEventWithType:NSLeftMouseUp ...
     [NSApp sendEvent:upEvent]; // dispatch mouse-up event
}

- (void)mouseUp:(NSEvent *)event
{
     [super mouseUp:event];
     // your code goes here ...
}


Roland


Roland, even easier:

// in subclassed NSSlider
- (void)mouseDown:(NSEvent *)event
{
	// do your stuff here, then...
	[super mouseDown:event];

}

works for me.

Ron,

I don't see how this way can act on mouse-up, with your code placed _before_ the call to super. Don't you need to have the slider track the mouse movement, and then when the mouse button is let up, do post processing? If I place my code before the [super mouseDown:event], the slider does not move under the cursor, and my action occurs before the slider's value changes, which is definitely odd behavior, and not the same as capturing mouse-up.

Roland

<blush>
Don't know what happened there, but of course you are right. It's not like that in my code, it's the right way around. Really just wanted to say that you don't need to actually have a mouseDown: method to get the mouseDown.


</blush>

Ron
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >Re: Catching NSSlider -mouseUp: events (workaround) (From: Ron Fleckner <email@hidden>)
 >Re: Catching NSSlider -mouseUp: events (workaround) (From: Roland Torres <email@hidden>)

  • Prev by Date: Re: Getting the context of a context menu
  • Next by Date: ScriptEditor thinks my command is a variable
  • Previous by thread: Re: Catching NSSlider -mouseUp: events (workaround)
  • Next by thread: NSArrayController and NSUnarchiveFromData
  • Index(es):
    • Date
    • Thread