• 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: Constraining a NSSlider to Certain Values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Constraining a NSSlider to Certain Values


  • Subject: Re: Constraining a NSSlider to Certain Values
  • From: Ron Fleckner <email@hidden>
  • Date: Mon, 7 Apr 2008 22:28:08 +1000


On 07/04/2008, at 10:10 PM, Peter Zegelin wrote:

On 07/04/2008, at 9:07 PM, Jean-Daniel Dupas wrote:


Le 7 avr. 08 à 12:14, Peter Zegelin a écrit :
I'm trying to constrain the value of an NSSlider (while it is being dragged) depending on the state of a modifier key and being totally new to Cocoa am getting nowhere really fast! For a start, I don't seem to be able to find a way to test for a modifier key during the actual drag.

Can anyone help me here?

thanks!

Peter

To get the current modifier state during an event, -[NSEvent modifierFlags];
And -[NSApplication currentEvent] or -[NSWindow currentEvent] to get the current event (if you do not already have it).

OK but given, say, my own slidercell subclass, which event should I check in and how do I get a ref to the sliders window? I'm currently using 'continueTracking' which seems to be the right event to override:


- (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint) currentPoint inView:(NSView *)controlView{
// how do I get the modifier keys here
// and set the slider to some value if say the command key is pressed


else
// do the default thing
return [super continueTracking:lastPoint at:currentPoint inView:controlView];


}

thanks for your help,

Peter

Hi Peter,

this post on CocoaBuilder by Shaun Wexler and the rest of the thread will help you I think:
<http://www.cocoabuilder.com/archive/message/cocoa/2006/3/5/157994>


In my slider subclass I use both trackingRects (-mouseMoved:) and - mouseDown: to detect modifier keys. Note the correct way to override -mouseDown: for sliders in the above post. It's a little non-intuitive.

HTH,

Ron_______________________________________________

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: 
 >Constraining a NSSlider to Certain Values (From: Peter Zegelin <email@hidden>)
 >Re: Constraining a NSSlider to Certain Values (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Constraining a NSSlider to Certain Values (From: Peter Zegelin <email@hidden>)

  • Prev by Date: Re: Constraining a NSSlider to Certain Values
  • Next by Date: Obj-C idioms for list based tasks
  • Previous by thread: Re: Constraining a NSSlider to Certain Values
  • Next by thread: Re: Constraining a NSSlider to Certain Values
  • Index(es):
    • Date
    • Thread