vcl/osx/salframeview.mm |   27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

New commits:
commit 4334ca4cd1fb99a450c797ead0a72570670930b0
Author:     Patrick Luby <[email protected]>
AuthorDate: Sat Jan 10 20:38:06 2026 -0500
Commit:     Patrick Luby <[email protected]>
CommitDate: Sun Jan 11 21:57:55 2026 +0100

    Related: tdf#170149 escape and return keys need the delete key special 
handling
    
    For some unknown reason, press-and-hold will fail after doing the
    following steps twice:
    
    - Arrowing into the input method's popup window
    - Arrowing out of the popup window
    - Pressing Delete, Backspace, Fn-Delete, Escape, or Return
    
    The only way I have found to reset the input method is to deactivate
    and then reactivate the input method.
    
    This patch applies the fix for the Delete, Backspace, and Fn-Delete
    keys to the Escape and Return keys.
    
    Change-Id: If1222800325d85758ed53f05be367ce770f32e6b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197002
    Reviewed-by: Patrick Luby <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm
index 37a7901d7046..62f62c6d56e7 100644
--- a/vcl/osx/salframeview.mm
+++ b/vcl/osx/salframeview.mm
@@ -1713,19 +1713,22 @@ static NSString* getCurrentSelection()
         if( ! [self handleKeyDownException: pEvent] )
         {
             sal_uInt16 nKeyCode = ImplMapKeyCode( [pEvent keyCode] );
-            if ( nKeyCode == KEY_DELETE && mpLastMarkedText )
+            if ( mpLastMarkedText && ( nKeyCode == KEY_DELETE || nKeyCode == 
KEY_ESCAPE || nKeyCode == KEY_RETURN ) )
             {
-                // tdf#42437 Enable press-and-hold special character input 
method
-                // Emulate the press-and-hold behavior of the TextEdit
-                // application by deleting the marked text when only the
-                // Delete key is pressed and keep the marked text when the
-                // Backspace key or Fn-Delete keys are pressed.
-                if ( mbTextInputWantsInsertText )
+                if ( nKeyCode == KEY_DELETE )
                 {
-                    if ( [pEvent keyCode] == 51 )
-                        [self insertText:[NSString string] 
replacementRange:NSMakeRange( NSNotFound, 0 )];
-                    else
-                        [self insertText:[mpLastMarkedText string] 
replacementRange:NSMakeRange( 0, [mpLastMarkedText length] )];
+                    // tdf#42437 Enable press-and-hold special character input 
method
+                    // Emulate the press-and-hold behavior of the TextEdit
+                    // application by deleting the marked text when only the
+                    // Delete key is pressed and keep the marked text when the
+                    // Backspace key or Fn-Delete keys are pressed.
+                    if ( mbTextInputWantsInsertText )
+                    {
+                        if ( [pEvent keyCode] == 51 )
+                            [self insertText:[NSString string] 
replacementRange:NSMakeRange( NSNotFound, 0 )];
+                        else
+                            [self insertText:[mpLastMarkedText string] 
replacementRange:NSMakeRange( 0, [mpLastMarkedText length] )];
+                    }
                 }
 
                 // Related: tdf#170149 Calling [self interpretKeyEvents:] with
@@ -1745,7 +1748,7 @@ static NSString* getCurrentSelection()
                 // doing the following steps twice:
                 // - Arrowing into the input method's popup window
                 // - Arrowing out of the popup window
-                // - Pressing Delete or Backspace or Fn-Delete
+                // - Pressing Delete, Backspace, Fn-Delete, Escape, or Return
                 // The only way I have found to reset the input method is to
                 // deactivate and then reactivate the input method.
                 NSTextInputContext *pInputContext = [NSTextInputContext 
currentInputContext];

Reply via email to