Felipe Monteiro de Carvalho wrote:
On Mon, Jan 30, 2012 at 11:55 AM, Mark Morgan Lloyd
<[email protected]> wrote:
Thanks for that Felipe. So if I'm reading you correctly, as a crude hack I
should be able to start by hooking OnKeyDown etc. as exposed by (instances
of) descendants of TWinControl. But there's probably more ethical ways to do
it based on at least partial replacement of elements of the LCL.
Maybe I am missunderstand here, but you want to send keyboard events
from the hardware to the LCL application correct? If yes, then No, you
dont want to hook to OnKeyDown. OnKeyDown is what the control handles
(actually usually the KeyDown virtual method), but is not the first
step in the event chain.
If you want to simulate a keyboard you have to send LM_KEYDOWN /
LM_KEYUP and UTF8Char messages to controls.
No. I don't want to simulate a keyboard, I want to be able to pick up an
Alt or Meta shift so that if my keyboard was engraved like
http://www.aplusdev.org/keyboard.html I could get the extra characters
into editing controls as UTF-8.
I've got something acceptable working with pure FPC, and envisage this
notation being useful internal to a program to specify ranges of numbers
etc.
Convenience routines for
sending those messages are located in the unit lcl/LCLMessageGlue.pas
in these routines:
function LCLSendKeyDownEvent(const Target: TControl; var CharCode:
Word; KeyData: PtrInt; BeforeEvent, IsSysKey: Boolean): PtrInt;
function LCLSendKeyUpEvent(const Target: TControl; var CharCode: Word;
KeyData: PtrInt; BeforeEvent, IsSysKey: Boolean): PtrInt;
function LCLSendCharEvent(const Target: TControl; var CharCode: Word;
KeyData: PtrInt; BeforeEvent, IsSysKey, ANotifyUserInput: Boolean):
PtrInt;
function LCLSendUTF8KeyPress(const Target: TWinControl; AUTF8Char:
TUTF8Char; IsSysKey: Boolean): PtrInt;
So these are the routines you want to use for a LCL-only solution.
For a system wide solution you would need to figure out how to get
your keyboard messages to X11.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus