Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSPanel I created from code won't accpet key Events

NSPanel I created from code won't accpet key Events
Thread Tools
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Jan 27, 2005, 05:58 AM
 
Hello,

I am dabbling with making a sort of on-screen menu that appears above other windows.

It contains a window for each menu item - and these windows are semi-transparent panels based off the 'roundTransparentWindow' sample code:

http://developer.apple.com/samplecod...entWindow.html



So far, so good.

However I would like the panels to accept keyDown: events. Which I can't seem to get them to do. They accept Mouse events - but not key events.

I have added the necessary FirstResponder methods to the window's main view - and they sort of work - as you can see from the output below:


The first time each window appears it's view Accepts FirstResponder and Becomes FirstResponder.

After that though (last few lines) - it accepts FirstResponder (when I click on the window) - but does not ever become FirstResponder.

If I try to type then I get a system beep - and no keyboard events are caught by any of the views.


Does anyone have any ideas why the Panels will not accept key input?

I suspect either it has something to do with either the panel being initWithContentRect:aRect styleMask:NSBorderlessWindowMask | NSNonactivatingPanelMask

or [panel setLevel:NSStatusWindowLevel];


below is the code:

Code:
// <code snipped>
Output when Run:
Code:
[Session started at 2005-01-27 11:56:36 +0000.] MoreBezels[4684]: ICeCoffEE APE: Can't get process serial number for current process (error 1011); not loading in this application 2005-01-27 11:56:37.466 MoreBezels[4684] The AppController has awokenFromNib. 2005-01-27 11:56:37.619 MoreBezels[4684] G4 TV Channel Selector Accepts First Responder 2005-01-27 11:56:37.619 MoreBezels[4684] G4 TV Channel Selector Accepts First Responder 2005-01-27 11:56:37.619 MoreBezels[4684] G4 TV Channel Selector Become First Responder 2005-01-27 11:56:37.676 MoreBezels[4684] G4 TV Channel Selector 2005-01-27 11:56:37.682 MoreBezels[4684] G4 TV Quit TVR app Accepts First Responder 2005-01-27 11:56:37.683 MoreBezels[4684] G4 TV Quit TVR app Accepts First Responder 2005-01-27 11:56:37.683 MoreBezels[4684] G4 TV Quit TVR app Become First Responder 2005-01-27 11:56:37.704 MoreBezels[4684] G4 TV Quit TVR app 2005-01-27 11:56:37.710 MoreBezels[4684] G4 TV Record Now - choosing channel Accepts First Responder 2005-01-27 11:56:37.711 MoreBezels[4684] G4 TV Record Now - choosing channel Accepts First Responder 2005-01-27 11:56:37.711 MoreBezels[4684] G4 TV Record Now - choosing channel Become First Responder 2005-01-27 11:56:37.728 MoreBezels[4684] G4 TV Record Now - choosing channel 2005-01-27 11:56:37.734 MoreBezels[4684] iconGenerator Accepts First Responder 2005-01-27 11:56:37.734 MoreBezels[4684] iconGenerator Accepts First Responder 2005-01-27 11:56:37.734 MoreBezels[4684] iconGenerator Become First Responder 2005-01-27 11:56:37.752 MoreBezels[4684] iconGenerator 2005-01-27 11:56:37.757 MoreBezels[4684] iconSwitching Accepts First Responder 2005-01-27 11:56:37.757 MoreBezels[4684] iconSwitching Accepts First Responder 2005-01-27 11:56:37.757 MoreBezels[4684] iconSwitching Become First Responder 2005-01-27 11:56:37.770 MoreBezels[4684] iconSwitching 2005-01-27 11:56:37.786 MoreBezels[4684] MoreBezels Accepts First Responder 2005-01-27 11:56:37.786 MoreBezels[4684] MoreBezels Accepts First Responder 2005-01-27 11:56:37.786 MoreBezels[4684] MoreBezels Become First Responder 2005-01-27 11:56:37.816 MoreBezels[4684] MoreBezels 2005-01-27 11:56:37.821 MoreBezels[4684] Put local Formac in DV Out mode Accepts First Responder 2005-01-27 11:56:37.822 MoreBezels[4684] Put local Formac in DV Out mode Accepts First Responder 2005-01-27 11:56:37.822 MoreBezels[4684] Put local Formac in DV Out mode Become First Responder 2005-01-27 11:56:37.842 MoreBezels[4684] Put local Formac in DV Out mode 2005-01-27 11:56:43.216 MoreBezels[4684] G4 TV Record Now - choosing channel Accepts First Responder 2005-01-27 11:56:45.104 MoreBezels[4684] G4 TV Record Now - choosing channel Accepts First Responder Executable “MoreBezels” has exited with status 0.
(Last edited by Diggory Laycock; Jan 27, 2005 at 01:04 PM. )
You know it makes sense. ☼ ☼ ☼ Growl.
     
Forum Regular
Join Date: Aug 2003
Status: Offline
Reply With Quote
Jan 27, 2005, 09:05 AM
 
Looks to me like you aren't entering a run loop. Sure you got the NSApplicationMain() function call in main.m?
-- Devin Lane, Cocoa Programmer
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Jan 27, 2005, 09:20 AM
 
Thanks for taking the time to look over it -

I've had a bit of a walk outside and re-read some of the cocoa book and come to the conclusion that I was confusing a WindowController and a Window.

I was trying to jam WindowController and Window code into the same class.

I've separated the code out and moved to a nib-based approach, and now and it's behaving much better.
You know it makes sense. ☼ ☼ ☼ Growl.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:07 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2