From 680047272572b3d9f9d590c17330c1a6800dde3c Mon Sep 17 00:00:00 2001 From: daboe01 Date: Fri, 30 Jan 2026 22:40:35 +0100 Subject: [PATCH] fixed: keystrokes from menu shortcuts are inserted into textviews --- AppKit/CPMenu/CPMenu.j | 1 + AppKit/CPTextView/CPTextView.j | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/AppKit/CPMenu/CPMenu.j b/AppKit/CPMenu/CPMenu.j index a0fbb3785..962307a66 100644 --- a/AppKit/CPMenu/CPMenu.j +++ b/AppKit/CPMenu/CPMenu.j @@ -1075,6 +1075,7 @@ var _CPMenuBarVisible = NO, if (self === [CPApp mainMenu]) [self _flashItemAtIndex:index]; + anEvent._isKeyEquivalent = YES; // prevent the menu keystroke from beeing inserted into textview [self performActionForItemAtIndex:index]; } else diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 1baff4b49..6c186de21 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1867,7 +1867,7 @@ Sets the selection to a range of characters in response to user action. } else { - [_typingAttributes setObject:[sender selectedFont] forKey:CPFontAttributeName]; + [_typingAttributes setObject:[sender convertFont:oldFont] forKey:CPFontAttributeName]; } } else @@ -2754,12 +2754,14 @@ var _CPCopyPlaceholder = '-'; var currentFirstResponder = [[CPApp keyWindow] firstResponder]; if (currentFirstResponder && [currentFirstResponder respondsToSelector:@selector(insertText:)]) - // setTimeout to prevent flickering - setTimeout(function(){ - [currentFirstResponder insertText:textToInsert] - }, 20); + var event = [CPApp currentEvent]; - // CRUCIAL: Clear the field immediately after grabbing its content. + if (!event._isKeyEquivalent) + setTimeout(function(){ + [currentFirstResponder insertText:textToInsert] + }, 20); + + // Clear the field immediately after grabbing its content. _CPNativeInputField.innerHTML = ''; };