0

Ok. I've been digging around trying to find a way to capture button up and down actions. I'm not even sure what the proper terminology in Xcode for this would be. It's pretty easy in MS Visual, but I can't seem to find how to do this with Xcode.

Essentially, I want to fire an action when the button is pressed down and held, and then another when the button is released.

I'm not really sure how to go about this. Any hints, or pointers in the right direction would be greatly appreciated!

jscs
  • 63,694
  • 13
  • 151
  • 195
butteryak
  • 11
  • 2

1 Answers1

0

You didn't specify, so I'm going to assume this is for the Mac and not iOS. You should read the NSResponder documentation. You can do exactly what you want with that.

edc1591
  • 10,146
  • 6
  • 40
  • 63
  • Yes, this is for Mac, sounds like what I was looking for, thanks much! – butteryak May 17 '11 at 01:28
  • I see how I can capture a mouse event with - (void)mouseDown:(NSEvent *)theEvent { } but I'm uncertain how that gets associated with a specific view object. – butteryak May 17 '11 at 06:56
  • Apple's documentation isn't really clear. It looks like you'll have to subclass `NSButton` and implement the `NSResponder` methods you want to use. – edc1591 May 17 '11 at 13:01
  • documentation isnt really clear, thats an understatement :) I'm having a challenging time with finding good information or a good book, what I'm finding is that xcode changes so much, that alot of info is out of date. any good book recomendations for 3.2.6? So yeah, thats what I was thinking I needed to do. It's all starting to make sense based on what I've been reading, but I learn from example best, and finding a good book, that covers the basics as well as more complex issues has been a challenge....thanks much! – butteryak May 17 '11 at 15:50
  • Check this stack overflow question: http://stackoverflow.com/questions/7571/cocoa-and-objective-c-resources That might give you some ideas of where to get help. As for me, I pretty much learned just by experimenting and looking at Apple's example projects. – edc1591 May 18 '11 at 02:26