Sven Barth wrote:
On 28.01.2012 18:38, Mark Morgan Lloyd wrote:
Ludo Brands wrote:
I'll start digging in and see where I get to, but any suggestions-
particularly relating to Linux- will be welcome.
Under X11 you can modify your keyboard to your likings. 4 levels per
key are
standard using Shift and 3 lvl key (Altgr on most non-Eglish kbd but
configurable to any key). Keys can be defined with their unicode code
(Uxxxx
format).
A nice howto here:
http://people.uleth.ca/~daniel.odonnell/Blog/custom-keyboard-in-linuxx11
.
As usual, locations of the kbd files differ from distribution to
distribution and even between versions.
Thanks Ludo. I'm already doing a bit of custom stuff to get A+ running
(arguably the largest free APL that still uses the original characters).
But the question remains: once inside a Lazarus app, can I hook keycodes
using a custom procedure, translate them to Unicode, and inject them
into the currently-focussed edit-capable control?
Take a look at the OnKeyDown and OnKeyUp events. Their "Key" argument is
a "var" one. You can "cancel" the default routine of the control the
handler is assigned to by setting the "Key" to "0" after you processed it.
E.g.
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift:
TShiftState
);
begin
Key := 0;
Edit1.SelText := #$e2#$9b#$a4;
end;
This will insert a "pentagramm" at the current cursor position of
"Edit1" (you'll only see it if you have a font that contains that
character).
You will then need to implement things like "key is hold down thus
insert character until released" yourself using a timer and OnKeyUp.
Also you can assign one event handler to multiple TEdits (or other
controls that support OnKeyDown/-Up) so you have only one routine which
uses the "Sender" parameter to differentiate the action to do.
PS: Maybe this is not the best solution (I never needed to do something
like this), but it should work.
Thanks Sven, doesn't sound too arduous. I'll investigate, it reminds me
of some keyboard handling I wrote for a Delphi comms app based on a
standard grid control.
I've got no intention of doing large-scale data entry or anything like
that, so I don't think I really need to consider things like Synedit at
this point. But it would be useful to be able to enter expressions into
e.g. a grid, a particular example- and what I'm going to use as the next
test app- being "shorthand" to populate tables for a filter that
transposes notes in a MIDI data stream.
--
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