• 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: NSSlider: differentiating mouseDown, mouseUp, mouseDragged
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSlider: differentiating mouseDown, mouseUp, mouseDragged


  • Subject: Re: NSSlider: differentiating mouseDown, mouseUp, mouseDragged
  • From: Brian Webster <email@hidden>
  • Date: Fri, 17 Jan 2003 11:24:09 -0600

On Friday, January 17, 2003, at 09:56 AM, email@hidden wrote:

I've tried subclassing NSSlider and putting overrides like this in the
subclass:

- (void)mouseUp:(NSEvent *)theEvent;
- (void)mouseDown:(NSEvent *)theEvent;
- (void)mouseDragged:(NSEvent *)theEvent;

But only the mouseDown: method ever gets called, not the other ones.

The reason for this is that NSlider is doing its own mouse tracking loop within the mouseDown: routine, rather than returning immediately and getting further events passed down to it. So it's fetching the events from the event queue itself using [NSApp nextEventMatchingMask:...], which makes it a little difficult to tell when the mouse up occurs.

One approach that might work would be to override mouseDown:, call super's implementation for that, and then when it returns, set your flag and send out an action yourself.

- (void)mouseDown:(NSEvent*)event
{
[super mouseDown:event];
isFinalAction = YES;
[NSApp sendAction:[self action] to:[self target] from:self];
isFinalAction = NO;
}

- (BOOL)isFinalAction
{
//Use this to determine whether it's the mouse up when the action is sent
return isFinalAction;
}

This would mean one additional action message being sent out, since NSSlider will still send one out on the mouse up event, but I think it would work OK.

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: [slightly OT] Cocoa development books in electronic form
  • Next by Date: Re: null values in NSArray ???
  • Previous by thread: Re: NSSlider: differentiating mouseDown, mouseUp, mouseDragged
  • Next by thread: null values in NSArray ???
  • Index(es):
    • Date
    • Thread