(Solved) Custom control KeyDown event lazarus / 31-LCL ---------------------------------------------------------------------- lainz · 2020-10-04 16:03 Hi, I'm making a ListBox with TCustomControl. What I need is when the user press the keys down and up fire the code that I wrote. I overrided KeyDown event, but it does nothing. I've seen in other controls the use of UTF8KeyPress, but I need KeyDown because I need the arrow keys, vk_up and vk_down. Any help is appreciated. Edit: Here is the source code: https://github.com/bgrabitmap/bgracontrols/blob/dev- bgracontrols/bclistboxex.pas ---------------------------------------------------------------------- Blaazen · 2020-10-04 16:38 KeyDown should work in everything derived from TCustomControl. I can only see that you don't call 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 inherited KeyDown(Key, Shift); ---------------------------------------------------------------------- winni · 2020-10-04 16:44 Hi! I just tested your BCListBoxEX. If you set the initial value of ItemHeight to 20 (and not 150) then you can see the Items. Two Bugs: * If you change the direction you have to type KeyUp or KeyDown twice * You start at the first item, but you will never reach it again with KeyUp. Winni ---------------------------------------------------------------------- lainz · 2020-10-04 16:54 I'm using trunk. I first made the logic in a TForm, but then I'm moving to TCustomControl to have it independently of the TForm. But in trunk it doesn't works, I can't move with the keys, maybe it's my trunk that doesn't works... Winni you're using FPC release? or trunk? Edit: using FPC 3.2.0 and Lazarus 2.0.10 doesn't works as well... ---------------------------------------------------------------------- lainz · 2020-10-04 16:58 Quote from: winni on October 04, 2020, 06:44:18 pmHi! I just tested your BCListBoxEX. If you set the initial value of ItemHeight to 20 (and not 150) then you can see the Items. Two Bugs: * If you change the direction you have to type KeyUp or KeyDown twice * You start at the first item, but you will never reach it again with KeyUp. Winni The idea was not to see the items to force the need of changing the scroll when moving with the keyboard. I've not tested the code with keyboard since it doesn't works on my setup ---------------------------------------------------------------------- lainz · 2020-10-04 17:00 Quote from: Blaazen on October 04, 2020, 06:38:28 pmKeyDown should work in everything derived from TCustomControl. I can only see that you don't call 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 inherited KeyDown(Key, Shift); Thanks, but adding that also doesn't works... ---------------------------------------------------------------------- Blaazen · 2020-10-04 17:17 Do you mean that KeyDown is not triggered at all or your code just does not work? Put there some DebugLn('KeyDown', inttostr(Key)); to see what happens. ---------------------------------------------------------------------- winni · 2020-10-04 17:26 Quote from: lainz on October 04, 2020, 06:54:23 pm Winni you're using FPC release? or trunk? Hi! fpc 3.04, Laz 2.010 Screenshot attached. Winni ---------------------------------------------------------------------- lainz · 2020-10-04 21:25 Quote from: Blaazen on October 04, 2020, 07:17:16 pmDo you mean that KeyDown is not triggered at all or your code just does not work? Put there some DebugLn('KeyDown', inttostr(Key)); to see what happens. Added that in top of the event and doesn't fire. Also added a breackpoint and doesn't fire as well. Quote from: winni on October 04, 2020, 07:26:55 pmQuote from: lainz on October 04, 2020, 06:54:23 pm Winni you're using FPC release? or trunk? Hi! fpc 3.04, Laz 2.010 Screenshot attached. Winni Thanks winni, so it's an FPC bug, since with 3.2.0 doesn't works and you confirm my code is buggy but at least fires on 3.0.4 I will report at the bugtracker https://bugs.freepascal.org/view.php?id=37871 ---------------------------------------------------------------------- lainz · 2020-10-04 22:02 Ok It works, the problem was I've not setup ActiveControl in the demo form.