Basically I’m making an iTunes controller. I need a way to detect if the next and back buttons are being held down so i can have them fast forward and rewind. In Studio I did this with the mouse down and mouse up handlers and detected how long it was sing the button was clicked to determine if it was being held down.
So, I was hoping there was a better way to detect a button being held down is ASOC. If not, how do i get the mouse down and mouse up handlers?
Thanks.
Rather than NSButtons, use custom NSViews and implement mouseDown: and mouseUp: handlers.
Is it not possible with an NSButton or is it just easier to use a custom NSView? Also, with the view, how would i make the view look like an NSButton. I’m using a custom NSButton from an ibplugin so that’ll probably make it more difficult. And what would the handlers look like that i type into my applescript file?
Thanks
You’d have to subclass a button anyway – it’s not standard button behavior.
Give it a suitable picture. Use an NSImageView if you like.
on mouseDown_(sender) and on mouseUp_(sender)
Actually you may be able to use a normal button and set it in IB to be continuous, so it sends recurring action messages while held down. Use setPeriodicDelay_interval_ to set the delay between calls.
I was able to get it to work by subclassing the custom NSButton i’m using. However, in my .h file i need to reference a file in the framework that has the custom NSButton, how do i do that. I can put the direct path to the file, but is that safe to do? Does it matter after it’s compiled?
If you’re using an .h file, you’re not subclassing it via ASObjC, so you’ll probably do better to ask in an Objective-C forum.
Oh wow, I didnt know that you could make AppleScript classes now. Everything’s working now, thanks.