Help to understand how do events work
Help to understand how do events work
- Subject: Help to understand how do events work
- From: eveningnick eveningnick <email@hidden>
- Date: Wed, 6 Oct 2010 15:39:01 +0400
Hello!
I have created a cocoa application that has unusual behavior: it has a
window (NSPanel), which does not activate the application, when it's
clicked. This window is ordered always on top of the other windows. So
it's like a "tooltip" window (basically it is a popup thing, that
drops down when a user types some combination of symols in another
application - which is a texteditor).
Anyway, i did it as following:
NSPanel *popupWindow = [[NSPanel alloc]
initWithContentRect:NSMakeRect(100,100,300,100)
styleMask:NSNonactivatingPanelMask | NSTitledWindowMask
backing:NSBackingStoreBuffered defer:NO];
[popupWindow setLevel:NSPopupMenuWindowLevel];
then i am showing it:
[popupWindow makeKeyAndOrderFront:nil];
This "window" behaves as expected: it is displayed on top of all
others, even if it's Application (in Dock, for ex) is not active. It
also dispatches all the clicks on controls (like NSPushButton's) to
these controls.
The problem for me is that i want to receive keyDown events with it.
But i am not sure if it is possible: in Apple documentation i found
that NSWindow (and NSPanel therefore) have keyDown method (that i
tried to override, having created a child class from NSPanel). But in
vain - this method is never called.
Neither is called mouseDown. How do buttons on this "panel"
successfully receive mouseDowns then, for example? Or, after i placed
on this panel an NSPushButton, i have seen that its dropdown list's
cursor is positioned according to the key pressed on a keyboard - this
means it processes keyDowns as well. But how? Could i process these
events (keyDown) too? Maybe i should make a child class of
NSApplication and rewrite -run method, watching for keydowns? What is
the "route" that events go in my case?
Thanks for the help
_______________________________________________
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