Recent

Author Topic: Lazarus method of listing all objects that can get focus, hot keys and clicks?  (Read 1704 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
Is there a method that can analyze a form and list every item that can get focus, accelerator keys and respond to clicks, like checkboxes, hot keys and speed buttons?

I need a feature where I can use the keyboard to reach any item in an application screen in one shot.

For those not acquainted with ace-jump in Emacs, or browser addons like Tridactyl, Vimium and Surfing Keys, you press a hotkey and all clickable or reachable items are overlaid with key pairs that enable you click a link or jump to an edit control.

It is shown in the attached image.

Surely that capability must exist, if not the hotkey jumping implementation.
« Last Edit: January 14, 2024, 11:42:46 pm by vfclists »
Lazarus 3.0/FPC 3.2.2

Thaddy

  • Hero Member
  • *****
  • Posts: 16399
  • Censorship about opinions does not belong here.
As far as I know it is not implemented, but it should be easy to do.
Just iterate over the form's Components recursively and check a component is focusable.
That probably needs some RTTI magic, but that is also easy.

Just file a feature request on the bug tracker.
There is nothing wrong with being blunt. At a minimum it is also honest.

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
As far as I know it is not implemented, but it should be easy to do.
Just iterate over the form's Components recursively and check a component is focusable.
That probably needs some RTTI magic, but that is also easy.

Just file a feature request on the bug tracker.

I have found a CanSetFocus event.

But how about elements that can receive clicks but can't receive focus, like some speedbuttons and hotkeys?

It looks like I have to iterate over every element of a form, see if it is actually visible, because it seems the Visible property may still be set if the item is covered by another, and if it is not an item that receives focus, check if some of the OnClick and RightClick events have methods attached to them.

How does the RTTI capabilities feature in this?

Lazarus 3.0/FPC 3.2.2

jamie

  • Hero Member
  • *****
  • Posts: 6791
Hmm, Accelerator key list maybe?
The only true wisdom is knowing you know nothing

AlexTP

  • Hero Member
  • *****
  • Posts: 2520
    • UVviewsoft
TForm has Controls property (UI controls) and Components property (non visual components). Enumerate them:
Code: Pascal  [Select][+][-]
  1.   for i:= 0 to ControlCount-1 do
  2.     showmessage(Controls[i].ClassName);
  3.  
« Last Edit: January 14, 2024, 06:04:25 pm by AlexTP »

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
Hmm, Accelerator key list maybe?

Is there a way to enumerate all the visible accelerator keys?
Lazarus 3.0/FPC 3.2.2

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
TForm has Controls property (UI controls) and Components property (non visual components). Enumerate them:
Code: Pascal  [Select][+][-]
  1.   for i:= 0 to ControlCount-1 do
  2.     showmessage(Controls[i].ClassName);
  3.  

It is not just enumerating the controls, it is about whether they can receive focus, or are accelerator keys or speed buttons, or even checkboxes/radio groups where each box could receive a click.

The buttons in radio groups and checkboxes should also be highlightable.

The idea is for leader key to place a transparent overlay on top of the screen with the key combinations for the controls on top of them. Hitting the appropriate key combo achieves the goal of navigating to the control, clicking it or both.

For instance on a control with multiple checkboxes each checkbox would have a key combo floating over it emulate selection or deselection.
Lazarus 3.0/FPC 3.2.2

jamie

  • Hero Member
  • *****
  • Posts: 6791
Yeah, well I know how to do that :D

Windows has a nice optional transparent window that can overlay any of the controls and you simply draw on the transparent,
once you have the list of all the controls and their Accelerator key names.
The only true wisdom is knowing you know nothing

BSaidus

  • Hero Member
  • *****
  • Posts: 606
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
I used previosly in Delphi the function
Code: Pascal  [Select][+][-]
  1. FindNextControl
  2.  
lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
<snip>

Windows has a nice optional transparent window that can overlay any of the controls and you simply draw on the transparent,
once you have the list of all the controls and their Accelerator key names.

How is that accomplished in Linux and Mac?

Can it be done directly in FreePascal
Lazarus 3.0/FPC 3.2.2

 

TinyPortal © 2005-2018