diff options
author | culler <culler> | 2021-03-02 19:04:35 (GMT) |
---|---|---|
committer | culler <culler> | 2021-03-02 19:04:35 (GMT) |
commit | f8fd3e1a60ef4499c05373076fd5266b00f60c9d (patch) | |
tree | 3cceee63c1396a7d5a5f5788d842724b3399dc79 /macosx/tkMacOSXMenu.c | |
parent | 6eed1c966158c4272228e45d6a27dc17b0f47016 (diff) | |
parent | 088f49b796a13ff9e4da248780bf3dd9fbe857f9 (diff) | |
download | tk-f8fd3e1a60ef4499c05373076fd5266b00f60c9d.zip tk-f8fd3e1a60ef4499c05373076fd5266b00f60c9d.tar.gz tk-f8fd3e1a60ef4499c05373076fd5266b00f60c9d.tar.bz2 |
Merge 8.6
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) |