Recent

Author Topic: TTabControl no keyboard support?  (Read 9206 times)

sky_khan

  • Guest
Re: TTabControl no keyboard support?
« Reply #15 on: June 03, 2017, 04:04:35 pm »
Ok. Still, you should check this :)

See attachment.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: TTabControl no keyboard support?
« Reply #16 on: June 03, 2017, 04:12:36 pm »
Anyways, wouldn't it nice if TTabControl has internal keyboard navigation feature?
Already answered it on my previous post. When you click the tab the tabsheet it self becomes focused this is the only focused state that a tabcontrol should have ee when it receives focus then the active tabsheet becomes focused automatically. At that point using the arrow keys it is possible to move between tab sheets with out problems. That should put things in the correct trajectory to start reporting other subtle bugs as well.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: TTabControl no keyboard support?
« Reply #17 on: June 03, 2017, 04:32:37 pm »
Keyboard support may have been implemented but it's not working on Linux Gtk2. Maybe there really is something wrong with my computer. Lets wait other Linux Gtk2 users to test to see if they also have same problem.

Or maybe can you write me an example but without using TActionList? Using TTabControl + TActionList works correctly on my system. But I can't make it works without TActionList.

EDIT:
  By clicking on the tab the tabit self becomes focused and a focus rect is drawn around the text in windows. Pressing tab then uses the default behavior that is to rotate through all the visible control in the form but you can still navigate the tab (when a tab is focused) using the arrow keys (the default behavior). The bug is that when the tabcontrol get focus it does not pass it along to the active tab instead it keeps it for it self. try setting the tabstops to false and see if you both rotate the visible controls with tab and when the tab sheet is focused the tabs with arrows.

Test result on my Linux system:
- No focus rect being drawn but I can see the tab is highlighted
- I can't navigate the tab using arrow keys, except if I provide my own code
- Set the TabStop to false does not help

@SkyKhan

Thank you for recommending me to use TPageControl. I know it but it is not suitable. You can see the screenshot, that is the program I'm currently building. On all of the tabs, there is only a big TDrawGrid. When user switch the tab, the DrawGrid will load data from a TDbf and show the list of titles of the memos. When user hover the mouse pointer on the grid, a hint will show up for more information. When user double click an item, an editor will show up for editing the content of the item. I put all efforts on a DrawGrid only and all the tabs will get all the benefits because the DrawGrid is shared between all tabs.
« Last Edit: June 03, 2017, 04:56:34 pm by Handoko »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: TTabControl no keyboard support?
« Reply #18 on: June 03, 2017, 09:36:37 pm »
@SkyKhan

Thank you for recommending me to use TPageControl. I know it but it is not suitable. You can see the screenshot, that is the program I'm currently building. On all of the tabs, there is only a big TDrawGrid. When user switch the tab, the DrawGrid will load data from a TDbf and show the list of titles of the memos. When user hover the mouse pointer on the grid, a hint will show up for more information. When user double click an item, an editor will show up for editing the content of the item. I put all efforts on a DrawGrid only and all the tabs will get all the benefits because the DrawGrid is shared between all tabs.

Nevertheless SkyKhan's suggestion is a good one. See the attached example of a 'shared' grid using TPageControl.

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: TTabControl no keyboard support?
« Reply #19 on: June 03, 2017, 11:37:25 pm »
Thank you howardpc for the trick. I can see you even tried to mimic the color. :D

Your and tazz's solutions both worked on my tests. And my code now is working correctly after I added 2 lines to make it stays focus:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.TabControl1Change(Sender: TObject);
  2. begin
  3.   // ...
  4.   TabControl1.SetFocus;
  5. end;
  6.  
  7. procedure TForm1.TabControl1MouseUp(Sender: TObject; Button: TMouseButton;
  8.   Shift: TShiftState; X, Y: Integer);
  9. begin
  10.   if (ActiveControl.Name = '') then TabControl1.SetFocus;
  11. end;

My problem of making TTabControl to work with keyboard can be considered solved. You can download and test my code if you want.

But now back to the 'real' issue. On my tests, I found that TTabControl keyboard navigation does not work on Linux Gtk2. Do you use Linux? Can you test TTabControl (not my code in test.zip) for me?

I want to submit a bug report. But I need someone to confirm the issue is really exist.
« Last Edit: June 04, 2017, 01:24:02 am by Handoko »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: TTabControl no keyboard support?
« Reply #20 on: June 04, 2017, 01:37:02 am »
But now back to the 'real' issue. On my tests, I found that TTabControl keyboard navigation does not work on Linux Gtk2. Do you use Linux? Can you test TTabControl (not my code in test.zip) for me?

I want to submit a bug report. But I need someone to confirm the issue is really exist.
As far as my experience goes, yes it should respond to keyboard, but I have no experience with tab control on gtk and I can't have an opinion about it. If everything else fails I would say that posting a bug report with your findings and get shot down by the team is preferable than not reporting at all.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: TTabControl no keyboard support?
« Reply #21 on: June 09, 2017, 10:03:26 am »
As you advised, I submitted a bug report:
https://bugs.freepascal.org/view.php?id=31986

Below is my test result on Lazarus 1.6.4 and 1.8.0RC2 using the test.zip.

On Ubuntu Mate 16.10 64-bit Lazarus 1.6.4/1.8.0RC2 Gtk2:
- TabControl cannot switch tab using keyboard.
- TabControl can switch tab using mouse click no matter TabStop is true or false.

On Win32 (Wine on Ubuntu) Lazarus 1.6.4/1.8.0RC2:
- If (TabControl.TabStop = True) the TabControl can switch tab using left and right keys.
- If (TabControl.TabStop = False) the TabControl still can receive focus and can switch tab using left and right keys. It should not able to receive focus because TabStop = False.
- If (TabControl.TabStop = False) the active tab can receive focus using mouse click but cannot switch tab using mouse click.
- The color of the background is blue, why?
« Last Edit: June 09, 2017, 10:11:43 am by Handoko »

 

TinyPortal © 2005-2018