Re: Make a window intercept key events
Re: Make a window intercept key events
- Subject: Re: Make a window intercept key events
- From: Pierre-Olivier Latour <email@hidden>
- Date: Fri, 30 Aug 2002 13:12:59 +0200
>
I have a little problem with a window which doesn't intercept key events. My
>
application is a bit particular: it has no user interface, except that
>
window which is opened by the app when needed to choose a particular
>
directory. But when I begin an NSOpenPanel as a sheet for that window, I
>
can't use the keyboard shortcuts (escape for "Cancel", ...), and I can't
>
fill the "Go to:" text field although it appeard to be selected.
>
Here is the part of my code for choosing the directory (my class is a
>
sub-class of NSWindowController):
>
>
[...]
>
>
Is there something wrong?
Background only apps cannot get key events (at least in 10.1). In X-Tunes I
use the following "Hack" to get them (it does not work perfectly though:
sometimes, key events are lost). Maybe it will work in your case:
#import <Carbon/Carbon.h>
+ (BOOL) stealKeyFocusForCurrentProcess
{
CPSProcessSerNum psn;
if((CPSGetCurrentProcess(&psn) == noErr) && (CPSStealKeyFocus(&psn) ==
noErr))
return YES;
return NO;
}
+ (BOOL) releaseKeyFocusForCurrentProcess
{
CPSProcessSerNum psn;
if((CPSGetCurrentProcess(&psn) == noErr) && (CPSReleaseKeyFocus(&psn) ==
noErr))
return YES;
return NO;
}
CPSxxx functions are declared in CPS.h, a header that declares some hidden
functions of the Carbon Processes API. You can find this header in ASM
source code (look for ASM in version tracker, then download the source code
from the author's web site).
_____________________________________________________________
Pierre-Olivier Latour email@hidden
Lausanne, Switzerland
http://www.pol-online.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.