[Lazarus] Hooking Synedit's cut and copy shortcuts
Martin
lazarus at mfriebe.de
Sat Dec 22 18:12:45 CET 2012
On 22/12/2012 17:04, Mark Morgan Lloyd wrote:
> Martin wrote:
>> On 21/12/2012 19:54, Mark Morgan Lloyd wrote:
>>> I'm in the middle of adding a shared clipboard to a text editor
>>> based on (Lazarus's) SynEdit. This is a simple stopgap based on a
>>> backend database, but also allows me to exercise PostgreSQL's
>>> listen/notify and hopefully also the Firebird equivalent both of
>>> which I want for something else.
>>>
>>> What I've got works fine if I use a menu entry to do copy or cut,
>>> but is there a simple way to hook SynEdit's reaction to ^C and ^X so
>>> that I can transfer stuff to the backend automatically?
>>>
>> OnProcessCommand
this is during keyboard processing too.
SynEdit will have translated it int ecCopy
>>
>> (if not that then OnProcessUserCommand commands are splitted into
>> build in and user. ecCopy ecCut ecPaste should be build in)
>>
>> The above only works if lynedit handles the keyboard.
>>
>> If you call SynEdit.CopyToClipboard (TAction might do that?) then the
>> above does not trigger
>>
>>
>>
>> use
>>
>> property OnCutCopy: TSynCopyPasteEvent read FOnCutCopy write
>> FOnCutCopy;
>> property OnPaste: TSynCopyPasteEvent read FOnPaste write FOnPaste;
>
> Thanks Martin, noted. As an interim measure I ended up detecting ^C
> etc. in the key-up event, which /might/ be safer since I'm already
> filtering keys to implement an APL-style keyboard and /might/ be the
> only way to handle
IIRC SynEdit handles ctrl-c in keydown
You can prevent SynEdit from handling the keystroke, by removing it from
SynEdit,KeyStrokes (or similar)
More information about the Lazarus
mailing list