Am Mittwoch 03 Oktober 2007 03:09:34 schrieb Marc Santhoff:
> Am Dienstag, den 02.10.2007, 18:50 +0200 schrieb Andreas Gick:
> > Thanks for the quick answers....
> >
> > Well there is a similar function in the source of fpgui that I included
> > as attachment (at around line 414), and I'm not sure, why it only works
> > with ASCII characters.
> >
> > But maybe I also need to clarify a bit more, what I want to do: At the
> > moment, I cannot type "ö" into an edit field, because that key isn't
> > mapped, but I can assign "ö" to a string variable and display it in the
> > edit field.
>
> When pressing a key the Xserver receives it because it is handling the
> input driver. Then an event of type XKeyPressed (or similar named) is
> sent to the application having the focus. If you release the key,
> XKeyReleased is sent with the key code as data.
>
> When an application is running on X it regularly handles the message
> loop and reads the messages received. After discriminating a key event
> it will probably translate the key code to a key symbol and forward it
> to the control focused, which is the edit box.
>
> So if you compile the code with debug defined you will most likely see
> the event getting translated by
>
> function TfpgApplicationImpl.KeySymToKeycode(KeySym: TKeySym): Word;
>
> to a char 'ö'. The question now is: where does it vanish on the way from
> the applications decoding to the "setText"-procedure of the edit box.
>
> I don't know anything about fpGUI's internals.
>
> HTH and good luck,
> Marc
>
>
> _________________________________________________________________
> To unsubscribe: mail [EMAIL PROTECTED] with
> "unsubscribe" as the Subject
> archives at http://www.lazarus.freepascal.org/mailarchives
Well the most obvious place, where the keycode could vanish is the following
procedure:
procedure TfpgEdit.HandleKeyChar(var AText: string;
var shiftstate: TShiftState; var consumed: boolean);
var
s: string;
prevval: string;
begin
prevval := Text;
s := AText;
consumed := False;
// Handle only printable characters
// Note: This is not UTF-8 compliant!
if (Ord(AText[1]) > 31) and (Ord(AText[1]) < 127) then
begin
if (FMaxLength <= 0) or (UTF8Length(FText) < FMaxLength) then
begin
DeleteSelection;
UTF8Insert(s, FText, FCursorPos + 1);
Inc(FCursorPos);
FSelStart := FCursorPos;
AdjustCursor;
end;
consumed := True;
end;
if prevval <> Text then
if Assigned(FOnChange) then
if prevval <> Text then
if Assigned(FOnChange) then
FOnChange(self);
if consumed then
RePaint
else
inherited HandleKeyChar(AText, shiftstate, consumed);
end;
I tried commenting out "if (Ord(AText[1]) > 31) and (Ord(AText[1]) < 127)
then" and the corresponding "begin end;" structure, but it didn't seem to
change anything.
Greets Andreas
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives