Recent

Author Topic: StaticText Visual indication on focus?  (Read 3138 times)

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
StaticText Visual indication on focus?
« on: October 14, 2014, 11:40:14 pm »
is there a visual indication when statictext is focused? (focused rect?)
added several controls on a form and a statictext

there is a tabstop property for statictext  i set it to true but nothing
i miss something?

Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: StaticText Visual indication on focus?
« Reply #1 on: October 14, 2014, 11:46:53 pm »
static text can't be focused so no focus line can be drawn, I think that the focusedControl property is there to allow you to select which control receives the focus when you tab in the statictext.
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

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: StaticText Visual indication on focus?
« Reply #2 on: October 14, 2014, 11:53:18 pm »
yes there is a property focusedcontrol
so the tabstop property is there to serve the fousedcontrol
and not to [Allow the user to navigate to this control]
Thank you  @taazz
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: StaticText Visual indication on focus?
« Reply #3 on: October 15, 2014, 03:08:17 am »
AFAIK, the fact that a text can be focused has nothing to do with the FocusControl property.


At least in Windows, text controls can be focused with tabulation keys (TAB or CTRL-TAB): using the WS_TABSTOP style for LTEXT/RTEXT/CTEXT controls. This is not bound to Delphi or Lazarus, but to Windows.

Delphi has just reproduced this behavior (so do Lazarus) with the TabStop property: http://docwiki.embarcadero.com/Libraries/XE7/en/Vcl.StdCtrls.TStaticText.TabStop

I admit it's a bit weird that nothing is visible when a text is focused, but anyway it's just working like this : texts get focus without any visible effect. BTW, there are not the only ones: Groupboxes, for instance, have the same behavior.


On another way, the FocusControl property is specific to Delphi/Lazarus-FreePascal (i.e. it's not related to Windows). It just set the focus to the desired control, if you press the mnemonic present in the caption of the concerned statictext/label.


So, to make it short:

- Tabstop: text can receive the focus with the tabulation keys (no visual indication),

- FocusControl: set the focus to another control, if text mnemonic (Alt+Key) is pressed.

** EDIT** That's also why Labels have a FocusControl property, but not TabStop/TabORder ones: they are not 'text controls' from the Windows point of view.
« Last Edit: October 15, 2014, 03:12:39 am by ChrisF »

 

TinyPortal © 2005-2018