| Summary: | Under MacOS X, key composition is not working properly | ||
|---|---|---|---|
| Product: | SDL | Reporter: | kuon <kuon> |
| Component: | events | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | CC: | maarten |
| Version: | HG 1.2 | ||
| Hardware: | PowerPC | ||
| OS: | Mac OS X 10.4 (Intel) | ||
| Attachments: | Patch which fixes the beeping when key equivalents (Cmd+key) are pressed | ||
This is already fixed in subversion for both SDL 1.2 and 1.3. Thanks! There seems to be a problem with this fix: every time I press Cmd+key, I hear an error beep. This is the same beep you hear in OS X applications when Cmd+key is not bound to anything. Our application (www.openmsx.org) is ported from Linux with very few changes and as a result none of the key combinations we use are known to Cocoa. However, we do use combinations with Cmd and hearing the error beep every time one is pressed is a bit annoying. I think the call to "interpretKeyEvents" is the one causing this, as disabling that solves the beep problem. But I expect that to break key composition. I am not familiar with Cocoa or with the SDL internals, so I'm a bit stuck here. Created attachment 237 [details]
Patch which fixes the beeping when key equivalents (Cmd+key) are pressed
Here is a patch against SDL 1.2.12 which makes sure there is no beep when a Cmd+key combo is pressed, while keeping the key composition functionality working. The credits for this patch go to BouKiCHi.
Note that it is impossible for SDL to know which Cmd+key combos are handled by the application and which are not, since the SDL event API does not include "I handled the event" type feedback. We decided it would be better to omit the beeping for non-handled events than to beep for handled events. This is the motivation for the "return YES;" in the overridden "performKeyEquivalent".
Also note that forwarding events to NSApp is skipped in fullscreen mode. Trying to minimize (Cmd+M) or hide (Cmd+H) the application in fullscreen mode has weird side effects, so it's better to ignore those requests.
|
The composition, for example alt+e then e should produce é on US keyboard, is not working under Mac OS X. When a key event is received, it should be processed by the MacOS X input server for correct composition to work. The following code is a fix to this problem: in QZ_DoKey() if (SDL_TranslateUNICODE) { if(state == SDL_PRESSED) { NSRect r = NSMakeRect(0.0, 0.0, 0.0, 0.0); NSText *fieldEditor = [[NSTextView alloc] initWithFrame:r]; [fieldEditor interpretKeyEvents:[NSArray arrayWithObject:event]]; } chars = [ event characters ]; numChars = [ chars length ]; } else { numChars = 0; } This is some code to test the functionality of the patch. NSText *fieldEditor should be cached somewhere.