Question

I'm having five Image Buttons. If a button was clicked by mouse, then the button went to Onstate. Now if i pressed Space button it will zoom the button's image in a seperate Window. The space button should not work when the button id in OFFstate. now can i trigger the Keyevent? i already referred Quicklook and working on that. any new ideas?

Was it helpful?

Solution

You don't need to trigger the key event, just respond to it as though it were any old method call from the button. After giving it a target and a selector, give it a key equivalent of @" " and respond to the key press accordingly:

- (void)someAction:(NSButton*)sender event:(NSEvent*)event {
    //...
    if ((sender.state == NSOnState) && (event.keyCode == 0x32)) {
        //Zoom
    }
    //...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top