Lazarus 1.8.0 "HHeelloo wwoorrlldd!!" double keystroke syndrome [SOLVED] lazarus / 1-Linux ---------------------------------------------------------------------- OH1KH · 2018-02-19 17:11 HI! Just have been forced to install Laz 1.8.0 / fpc 3.0.4 as a project that I'm supporting does compile, but not run any more when compiled with Laz 1.6.4/fpc3.0.2. Resulting binaries give PPI-error at runtime. So with Laz 1.8.0 compiled they run ok. But program has an input area that now doubles all keystrokes. Most of edit boxes work ok, but until now at least this one does not. That would be a "little thing". Big trouble is that Lazarus source code editor works in same way !!!! Typing new text to source code editor: hello gives hello. Without backspaces it is hheelllloo ! Other way to do all editing is external editor and then cut/paste to source code editor. After some googling I did remove IBus, no help. Installed it again, no help. Tried to change: export GTK_IM_MODULE="" export QT_IM_MODULE="" export XMODIFIERS="@im=none" NO help. Found https://forum.lazarus.freepascal.org/index.php/topic,6231.msg234 819.html#msg234819 It is an old chain, but at the end one message from alexander is about year old. He states that Laz works with command line below. But complied programs have same problem. GTK_IM_MODULE=gtk-im-context-xim  lazarus For me this starting way did not give any help at all. System is Fedora 26  / Openbox-LXDE Any help !!! Please !!! -- Saku OH1KH ---------------------------------------------------------------------- Cyrax · 2018-02-19 17:29 Open terminal window and paste & execute following clause in there : export | grep LANG Then paste output of the command here. ---------------------------------------------------------------------- Handoko · 2018-02-19 17:48 Hello OH1KH, Welcome to the forum. You may want to read this: https://forum.lazarus.freepascal.org/index.php/topic,39213.msg268286.h tml#msg268286 ---------------------------------------------------------------------- JD · 2018-02-19 20:39 Happened to me too. Thanks to others like Handoko, I was able to correct it quickly See https://forum.lazarus.freepascal.org/index.php/topic,39799.msg2741 42.html#msg274142 JD ---------------------------------------------------------------------- ceh2624 · 2018-03-07 01:54 The simplest solution is often the best one... Go to Konsole or your favourite bash shell and type in this command: ibus exit ---------------------------------------------------------------------- OH1KH · 2018-03-08 10:23 Hi! I removed IBUS. Did not hep. Played some time with input method selector (logged in and out) and suddenly at some point double echo disappeared. I am not sure what made it. Btw someone asked to  export | grep LANG and paste here: declare -x LANG="fi_FI.UTF-8" So everything LOOKS now OK. But it is just a look ! At the program there is TMemo that has action "OnKeyPress" in use. It calls subroutine that gets "key:char" as parameter. Purpose is to send that char as CW (=morse code). Now when typing to memo text looks normal: "hello world", but subroutine sends it morse code as "hheelloo  wwoorrlldd". Subroutine gets called twice for every key press while it should be called only once. Source has not been touched, and linux is not updated (upd only Lazarus/FPC) and this program part worked completely ok compiled with Lazarus 1.6.4/Fpc3.0.2 But not any more with 1.8.0/3.04. Sad but true! I have no more ideas. And googling this kind of event gives lot more less than with double echo on screen. (I do not even have idea what search words to use for this case) -- Saku ---------------------------------------------------------------------- Thaddy · 2018-03-08 10:47 It is not related to FPC it is a known Fedora issue. ---------------------------------------------------------------------- OH1KH · 2018-03-08 16:35 If it is "known Fedora issue" please give some words to google to get right hit for that. Thank you. ---------------------------------------------------------------------- Thaddy · 2018-03-08 16:51 Are you serious??? If you use Fedora you would know about https://bugzilla.redhat.com/index.cgi ---------------------------------------------------------------------- OH1KH · 2018-03-08 17:15 That does not lead to anywhere. With "double keyboard events" I have 44 hits and with quick look  none seems to be related to this.  I do not feel bugzilla very good fix source. More just place for complain/feedback to developers. Just one thing I forgot to say: It is only letters that double them selfs, not numbers. And I can not understand that same source compiled in same computer works with 1.6.4/3.0.2 but not with 1.8.0/3.0.4 My opinion is that Laz/FPC has the problem. Either the old version had fault (and so produced a working program) or the new version has the fault. Not Fedora or source, that has not changed at all during Laz/fpc upgrade. As this is not leading to anywhere I have to start  thinking some kind of filter inside the subroutine. It is just a bit tricky as sometimes there really are words with 2 same letters besides. Depending what language is used there may be many of those words. ---------------------------------------------------------------------- JuhaManninen · 2018-03-08 17:39 Quote from: OH1KH on March 08, 2018, 11:23:13 amPlayed some time with input method selector (logged in and out) and suddenly at some point double echo disappeared. I am not sure what made it. So it works now, right? I think everybody with the problem have been able to fix it so far by tweaking IBUS or whatever settings. I personally have not experienced it, maybe because I use KDE. Everything just works here. Do you need both Lazarus 1.6.0 and 1.8.0 in the same computer? There is no quick fix coming for the problem because nobody understands the LCL-GTK2 code enough. There were attempts to fix it, but a fix for one machine caused it appear in another machine. Welcome to GTK2 ... See the issue:  https://bugs.freepascal.org/view.php?id=30863 and its related issues. ---------------------------------------------------------------------- JD · 2018-03-08 18:11 Quote from: OH1KH on March 08, 2018, 06:15:21 pmAs this is not leading to anywhere I have to start  thinking some kind of filter inside the subroutine. It is just a bit tricky as sometimes there really are words with 2 same letters besides. Depending what language is used there may be many of those words. Did you try what I did in the link I posted above? It solved it for me. JD ---------------------------------------------------------------------- OH1KH · 2018-03-09 04:41 I think I know now how Lazarus (fpc) is changed. This is simple test that I did and it shows the problem. It is partially copy of the program in question Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Memo1: TMemo;    Memo2: TMemo;    procedure Memo1KeyPress(Sender: TObject; var Key: char);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: char);  var s : string;begin  if key <> '' then   Begin    key := UpperCase(key)[1];   end;  if (key in ['A'..'Z']) or (key in ['0'..'9']) or (key = '=') or   (key = '?') or (key = ',') or (key='.') or (key='/') or (key = ' ') or   (key = '<') or (key = '>') or (key = ':') or (key = ')') or (key = '(') or   (key = ';') or (key = '@') or (key = 'ß') or (key ='Ü') or (key ='Ö') or   (key = 'Ä') then  begin    Memo2.Lines.Add(key);  end;end;end.                                  Now the difference lays in UTF-8 (was not in Laz 1.6.4), I think. This does not work any more:     key := UpperCase(key)[1]; If that is commented out typing letters (with caps locked) produces just one echo to Memo2. If it is there then double echo to Memo2 happens. Now I just have to find a way to upcase the key. NO!!!   UTF8UpperCase(key)[1]; does NOT work!! There must be some other way to do it. ---------------------------------------------------------------------- dbannon · 2018-03-09 05:44 Hmm, I just tried your code on Ubuntu with 1.8.0 and I saw double char. So, instead of messing with Key, I declared a new, 'MyKey', copied contents of key to it and used that in the code (actually only the A..Z test) and it worked fine. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: char);var s : string;  MyKey : char;begin  MyKey := Key;if Mykey <> '' then  Begin  Mykey := UpperCase(key)[1]; end; if (Mykey in ['A'..'Z']) or (key in ['0'..'9']) or (key = '=') or (key = '?') or (key = ',') or (key='.') or (key='/') or (key = ' ') or (key = '<') or (key = '>') or (key = ':') or (key = ')') or (key = '(') or (key = ';') or (key = '@') or (key = 'ß') or (key ='Ü') or (key ='Ö') or (key = 'Ä') thenbegin  Memo2.Lines.Add(Mykey);end;end; In fact the procedure is called twice (it must be Key can only hold one key press) when you get your double chars, that says to me the underlying system is reacting to you changing Key. (might be nicer to put all those test characters in one set ...) Davd ---------------------------------------------------------------------- OH1KH · 2018-03-09 15:47 Hi! Simple solution, but hard to find. Tried 10^n variations to make locase to upcase without making doubling. No luck. Something has changed because now var Key works "backwards" pushing upcase to key event. Thanks for help !