• 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: NSSliderCell question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSliderCell question


  • Subject: Re: NSSliderCell question
  • From: email@hidden
  • Date: Thu, 23 Jul 2009 23:15:31 -0700

I'll follow up on that tomorrow. Thanks,

Patrick

Hi,

I am using the following two methods for a scrolling number box which
is essentially a slider in the form of a NSTextField subclass. I have
yet to implement this for my custom sliders but maybe this is a good
starting point for you? When I first dabbled with custom sliders all
I did was override the mouseUp, mouseDown, mouseDragged methods etc
now my custom sliders are subclasses of NSControl rather than NSSlider.


-(void)mouseUp:(NSEvent*)theEvent
{
	if(drag) drag = NO;
}

-(void)mouseDragged:(NSEvent*)theEvent
{
	float val = [self floatValue];

	if(!drag) {
		// float start_x = [self convertPoint: [theEvent locationInWindow]
fromView: nil].x;
		start_y = [self convertPoint:[theEvent locationInWindow] fromView:
nil].y;
		prev_y = start_y;
		drag = YES;
	};

	// key modifier key flags
	unsigned int flags;
	flags = [theEvent modifierFlags];

	float next_y = [self convertPoint:[theEvent locationInWindow]
fromView: nil].y;
	float deltaY = (next_y - prev_y) / dragSize;
	prev_y = next_y;

	if(flags & NSAlternateKeyMask) deltaY *= fineGrain;
	val += range * deltaY;

	[self checkBounds:&val];
	[self setFloatValue:val];

	// continuously send the action
	[self sendAction:(SEL)[self action] to:(id)[self target]];
}

_______________________________________________

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


  • Prev by Date: Re: Screen Saver test button click notification
  • Next by Date: Re: Challenge: Block Main Thread while Work is done, with Timeout
  • Previous by thread: Re: NSSliderCell question
  • Next by thread: Comparing NSImages
  • Index(es):
    • Date
    • Thread