• 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: iTunes like Fast Forward and Rewind Buttons
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iTunes like Fast Forward and Rewind Buttons


  • Subject: Re: iTunes like Fast Forward and Rewind Buttons
  • From: Seth Willits <email@hidden>
  • Date: Fri, 16 Mar 2012 12:14:06 -0700

On Mar 15, 2012, at 11:53 PM, Peter Zegelin wrote:

> I need to implement something akin to the iTunes Fast Forward or Rewind buttons, where a quick mouse click has a different action to when the button is pressed for a longer time. I also need to link this action to a short or long press of an arrow key on the keyboard. Before I have a go myself does anyone know of an example out there?
>
> I am fairly sure I can implement the mouse click part myself but am not really sure how to go about adding keyboard support. Any ideas?


Assuming you need the "long" action to be repeated at regular intervals, here's something I slapped together for you to start with:



- (void)mouseDown:(NSEvent *)event
{
	mDownTime = [NSDate timeIntervalSinceReferenceDate];
	mDelayForScrubTimer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(beginScrubbing:) userInfo:nil repeats:NO];
}


- (void)mouseUp:(NSEvent *)event
{
	[mDelayForScrubTimer invalidate];
	mDelayForScrubTimer = nil;

	[mScrubTimer invalidate];
	mScrubTimer = nil;

	if ([NSDate timeIntervalSinceReferenceDate] - mDownTime < 0.2) {
		NSBeep();
		NSLog(@"Jump");
	} else {
		NSLog(@"End Scrubbing");
	}
}



- (void)keyDown:(NSEvent *)event
{
	if ([event isARepeat]) return;

	<same as mouseDown>
}


- (void)keyUp:(NSEvent *)event
{
	<same as mouseUp>
}



- (void)beginScrubbing:(id)timer
{
	[mDelayForScrubTimer invalidate];
	mDelayForScrubTimer = nil;

	mScrubTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(scrubTimer:) userInfo:nil repeats:YES];
}


- (void)scrubTimer:(id)timer
{
	NSBeep();
	NSLog(@"Scrub");
}





--
Seth Willits


_______________________________________________

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: 
 >iTunes like Fast Forward and Rewind Buttons (From: Peter Zegelin <email@hidden>)

  • Prev by Date: Re: NSViewAnimation fade[In/Out]effect not working
  • Next by Date: Re: Transition from [NSEvent phase] to [NSEvent momentumPhase]
  • Previous by thread: Re: iTunes like Fast Forward and Rewind Buttons
  • Next by thread: NSRuleEditor with variable-height rows?
  • Index(es):
    • Date
    • Thread