Skip to content

Remove and ReAdd KeyboardShortcut on Filter Input string#363

Merged
fantaisie-software merged 3 commits intofantaisie-software:develfrom
ChrisRfr:devel
Apr 1, 2026
Merged

Remove and ReAdd KeyboardShortcut on Filter Input string#363
fantaisie-software merged 3 commits intofantaisie-software:develfrom
ChrisRfr:devel

Conversation

@ChrisRfr
Copy link
Copy Markdown
Contributor

For the Filter Input String in UserInterface, ProjectPanel and ProcedureBrowser, remove the 4 main shortcuts (Ctrl+A, Ctrl+C, Ctrl+X, Ctrl+V) on Focus and recreate them on LostFocus.

On Filter Input string, remove the 4 main shortcuts (Ctrl+A, Ctrl+C, Ctrl+X, Ctrl+V) on Focus and recreate them on LostFocus.
For Filter Input string in UserInterface, ProjectPanel and ProcedureBrowser
@fantaisie-software
Copy link
Copy Markdown
Owner

May be it can be done in generic way when the scintilla component loose/gain its focus ?

@ChrisRfr
Copy link
Copy Markdown
Contributor Author

Yeah, that would be great, but I'm not sure where to do that for the Scintilla gadget.
In any case, you can delete/archive this PR.

@ChrisRfr
Copy link
Copy Markdown
Contributor Author

I took a quick look for the generic way but I don't know how to do it easily, without Focus/LostFocus events on Scintilla Gadget or on the Source Container Gadget.

@ChrisRfr
Copy link
Copy Markdown
Contributor Author

I tried with the code below, but without success, I'm not receiving any Focus/LostFocus events!
Do you have any idea how this could be done ?

#SCN_SETFOCUS  = 2021
#SCN_KILLFOCUS = 2022
  
ProcedureDLL ScintillaCallBack(EditorGadget, *scinotify.SCNotification)

  Select *scinotify\nmhdr\code
    Case #SCN_SETFOCUS
      MessageRequester("Scintilla", "Scintilla SETFOCUS") ; Restore the 4 keyboard shortcuts previously removed on #SCN_KILLFOCUS event. It is used in this ScintillaGadget
      For item = 0 To #MENU_LastShortcutItem
        Select KeyboardShortcuts(item)
          Case #PB_Shortcut_Control | #PB_Shortcut_C, #PB_Shortcut_Control | #PB_Shortcut_X, #PB_Shortcut_Control | #PB_Shortcut_V, #PB_Shortcut_Control | #PB_Shortcut_A
            AddKeyboardShortcut(#WINDOW_Main, KeyboardShortcuts(item), item)
        EndSelect
      Next
      
    Case #SCN_KILLFOCUS
      MessageRequester("Scintilla", "Scintilla LostFocus"); Remove the 4 main keyboard shortcuts to restore the standard behavior for StringGadget text
      RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Control | #PB_Shortcut_C)
      RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Control | #PB_Shortcut_X)
      RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Control | #PB_Shortcut_V)
      RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Control | #PB_Shortcut_A)

@ChrisRfr
Copy link
Copy Markdown
Contributor Author

It works with the right values, I'll add it to this PR and remove the previous changes made on String (Lost)Focus events

  #SCN_SETFOCUS  = 2028
  #SCN_KILLFOCUS = 2029

Generic-Way on the ScintillaGadget using Set(Kill)Focus events to remove or restaure the main keyboard and get the standard behavior for StringGadget text
@ChrisRfr
Copy link
Copy Markdown
Contributor Author

Done for the "Generic-Way" on the ScintillaGadget using Set(Kill)Focus events to remove or restaure the main keyboard shortcuts and get the standard behavior for StringGadget text

@fantaisie-software
Copy link
Copy Markdown
Owner

Looks good! Thanks for this useful patch

@fantaisie-software fantaisie-software merged commit a178d25 into fantaisie-software:devel Apr 1, 2026
@kenmo-pb
Copy link
Copy Markdown
Contributor

kenmo-pb commented Apr 1, 2026

PB_Shortcut_Control is correct for Windows and Linux, but should this be using PB_Shortcut_Command instead to be correct on MacOS?

@ChrisRfr
Copy link
Copy Markdown
Contributor Author

ChrisRfr commented Apr 2, 2026

Yes, you're right, I completely missed it. Grrr

However, even though the modification is simple, I don't have a Mac around, so I'm a bit hesitant to do it without testing it.
If you have a Mac, would you like to add it ? If not, I'm still confident enough to be able to do it without testing

ScintillaHighlighting.pb

Case #SCN_SETFOCUS
  ; Restore the 4 keyboard shortcuts previously removed on #SCN_KILLFOCUS event. They are used in this ScintillaGadget
  For item = 0 To #MENU_LastShortcutItem
    Select KeyboardShortcuts(item)
      CompilerIf #CompileLinux | #CompileWindows
        Case #PB_Shortcut_Control | #PB_Shortcut_C, #PB_Shortcut_Control | #PB_Shortcut_X, #PB_Shortcut_Control | #PB_Shortcut_V, #PB_Shortcut_Control | #PB_Shortcut_A
          AddKeyboardShortcut(#WINDOW_Main, KeyboardShortcuts(item), item)
      CompilerElse ; MacOS
        Case #PB_Shortcut_Command | #PB_Shortcut_C, #PB_Shortcut_Command | #PB_Shortcut_X, #PB_Shortcut_Command | #PB_Shortcut_V, #PB_Shortcut_Command | #PB_Shortcut_A
          AddKeyboardShortcut(#WINDOW_Main, KeyboardShortcuts(item), item)
      CompilerEndIf
    EndSelect
  Next
  
Case #SCN_KILLFOCUS
  ; Remove the 4 main keyboard shortcuts to restore the standard behavior for StringGadget text
  CompilerIf #CompileLinux | #CompileWindows
    RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Control | #PB_Shortcut_C)
    RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Control | #PB_Shortcut_X)
    RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Control | #PB_Shortcut_V)
    RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Control | #PB_Shortcut_A)
  CompilerElse ; MacOS
    RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Command | #PB_Shortcut_C)
    RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Command | #PB_Shortcut_X)
    RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Command | #PB_Shortcut_V)
    RemoveKeyboardShortcut(#WINDOW_Main, #PB_Shortcut_Command | #PB_Shortcut_A)
  CompilerEndIf

@ChrisRfr
Copy link
Copy Markdown
Contributor Author

ChrisRfr commented Apr 2, 2026

I've added it , but since I don't have a Mac, I'll let Fred test it, approve it

ps: Thanks Fred for #SCN_FOCUSIN, #SCN_FOCUSOUT, already defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants