diff options
author | Kevin Walzer <kw@codebykevin.com> | 2021-03-06 01:14:21 (GMT) |
---|---|---|
committer | Kevin Walzer <kw@codebykevin.com> | 2021-03-06 01:14:21 (GMT) |
commit | b8953821c2fd3ff58885138ddd3037eb17ca79fe (patch) | |
tree | 3fd20901602c3699cc6d2730342316eea233a8fe /macosx/tkMacOSXMenu.c | |
parent | 1e4967476d036d15872bf52495fb316098a50394 (diff) | |
parent | 0a9213075871ce2995c09448b33795b1ae53118e (diff) | |
download | tk-b8953821c2fd3ff58885138ddd3037eb17ca79fe.zip tk-b8953821c2fd3ff58885138ddd3037eb17ca79fe.tar.gz tk-b8953821c2fd3ff58885138ddd3037eb17ca79fe.tar.bz2 |
Replacing my printer code with a complete implementation courtesy of Harald Oehlmann; adding Michael Schwartz's GDI code after light tweaking, more extensive review and re-work needed to build; need to review and add Michael Schwartz's script-level implementation for printing text files and canvas widgets based on these C primitives
Diffstat (limited to 'macosx/tkMacOSXMenu.c')
-rw-r--r-- | macosx/tkMacOSXMenu.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 19a7019..321d308 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -189,6 +189,34 @@ TKBackgroundLoop *backgroundLoop = nil; { return (_tkSpecial == special); } + +/* + * There are cases where a KeyEquivalent (aka menu accelerator) is defined for + * a "dead key", i.e. a key which does not have an associated character but is + * only meant to be the start of a composition sequence. For example, on a + * Spanish keyboard both the ' and the ` keys are dead keys used to place + * accents over letters. But ⌘` is a standard KeyEquivalent which cycles + * through the open windows of an application, changing the focus to the next + * window. + * + * The performKeyEquivalent callback method is being overridden here to work + * around a bug reported in [1626ed65b8]. When a dead key that is also as a + * KeyEquivalent is pressed, a KeyDown event with no characters is passed to + * performKeyEquivalent. The default implementation provided by Apple will + * cause that event to be routed to some private methods of NSMenu which raise + * NSInvalidArgumentException, causing an abort. Returning NO in such a case + * prevents the abort, but does not prevent the KeyEquivalent action from being + * invoked, presumably because the event does get correctly handled higher in + * the responder chain. + */ + +- (BOOL)performKeyEquivalent:(NSEvent *)event +{ + if (event.characters.length == 0) { + return NO; + } + return [super performKeyEquivalent:event]; +} @end @implementation TKMenu(TKMenuPrivate) |