Lazarus

Programming => Packages and Libraries => SynEdit => Topic started by: Borneq on December 10, 2019, 07:43:56 pm

Title: Synedit wants too more keys
Post by: Borneq on December 10, 2019, 07:43:56 pm
If Synedit control has focus, ^N add empty line and I prefer add new editor.
How do it?,
- remove several keystrokes from SynEdit?
- or (better) all keys will handled at first by MianForm and menu,settings KeyPrev=true on MainForm not helps
--
Solution of first:
Code: Pascal  [Select][+][-]
  1. var
  2.  CmdIndex: integer;
  3. begin
  4. ....
  5.   CmdIndex:=fSynEdit.Keystrokes.FindCommand(ecInsertLine);
  6.   fSynEdit.Keystrokes.Delete(CmdIndex);
  7.  
Title: Re: Synedit wants too more keys
Post by: Martin_fr on December 10, 2019, 08:35:46 pm
Plenty of options....

TForm has
Form1.KeyPreview := True;

IIRC, event then go first to Form.KeyDown or maybe KeyPressed. Not sure.

SynEdit has events in the following order:
Code: Pascal  [Select][+][-]
  1.     property OnKeyDown
  2.  
  3.     procedure RegisterBeforeKeyDownHandler(AHandlerProc: TKeyEvent);
  4.  
  5. //Then if a keycombo was found
  6.    // depending on the command, either (only one is called...)
  7.     OnProcessUserCommand   or  OnProcessCommand
  8.    //   they receive "var Command: TSynEditorCommand;" which you can set to ecNone, to prevent the key from being handled.
  9. // End of  if a keycombo was found
  10.  
  11.  
  12.     OsKeyPressed
  13.  
  14.     procedure RegisterBeforeKeyPressHandler(AHandlerProc: TKeyPressEvent);
  15. or (not sure which)
  16.     procedure RegisterBeforeUtf8KeyPressHandler(AHandlerProc: TUTF8KeyPressEvent);
  17.  
  18.  
  19.     OnKeyUp
  20.     procedure RegisterBeforeKeyUpHandler(AHandlerProc: TKeyEvent);
  21.  

OnKeyPressed, and OnKeyUp only run AFTER keycombo detection.
And if a keycombo was found, then KeyPressed will NOT run.

So you can hook the above events
Or you can drop the keycombo, that you do not like. (KeyStrokes is a propery of SynEdit in the ObjectInspector)
Title: Re: Synedit wants too more keys
Post by: Borneq on December 10, 2019, 08:42:32 pm
Code: Pascal  [Select][+][-]
  1. Form1.KeyPreview := True;
helps with Ctrl+Tab
Title: Re: Synedit wants too more keys
Post by: Martin_fr on December 10, 2019, 10:33:33 pm
For tab: SynEdit.WantsTab := False

Have to test what all this affects.
TinyPortal © 2005-2018