* * *

Author Topic: TComboBox.AutoSelect has no effect  (Read 1019 times)

RolfW

  • New member
  • *
  • Posts: 10
TComboBox.AutoSelect has no effect
« on: February 07, 2018, 12:16:08 pm »
Hi,
the TComboBox.Text is always selected (receiving focus/selecting an item) regardless of the AutoSelect setting. Don't understand what's meant by "The Enter key is pressed" in the help file. Can't see that "Enter" has any effect.
Thanks,
Rolf

jamie

  • Sr. Member
  • ****
  • Posts: 430
Re: TComboBox.AutoSelect has no effect
« Reply #1 on: February 08, 2018, 11:40:01 pm »
AutoSelect just makes what ever is in the EDIT portion of the Tcombobox become selected when you move
from one control to this control.

 The Docs state the Text property is what is currently showing in the EdIT box of the combobox.

RolfW

  • New member
  • *
  • Posts: 10
Re: TComboBox.AutoSelect has no effect
« Reply #2 on: February 09, 2018, 10:16:50 am »
Hi jamie,
I've set AutoSelect to false. But the text in the edit protion of the ComboBox is selected regardless of this setting when the combobox is focused.
Rolf

ASerge

  • Hero Member
  • *****
  • Posts: 588
Re: TComboBox.AutoSelect has no effect
« Reply #3 on: February 09, 2018, 04:12:13 pm »
I've set AutoSelect to false. But the text in the edit protion of the ComboBox is selected regardless of this setting when the combobox is focused.
I do not know how on other platforms, but in Windows text selection in ComboBox is the default behavior. LCL with AutoSelect = True additionally selects all the text. In order to change the default behavior, in the OnEnter handler, put
Code: Pascal  [Select]
  1. (Sender as TComboBox).SelLength := 0;
In this case, the behavior will depend on the AutoSelect property.

RolfW

  • New member
  • *
  • Posts: 10
Re: TComboBox.AutoSelect has no effect
« Reply #4 on: February 16, 2018, 07:36:42 pm »
Meanwhile I've created a TComboBox descended component (TRWComboBox) which acts on activation in the same way as a TEdit control does (Windows, csDropDown, AutoSelect=false):
  - Nothing is selected at activation
  - Activation by key: The previous selection is restored
  - Activation by mouse: The selection follows the mouse cursor

It's Windows only. I think this is a Windows only problem.

Source code attached. Any response is welcome.

Rolf

ASerge

  • Hero Member
  • *****
  • Posts: 588
Re: TComboBox.AutoSelect has no effect
« Reply #5 on: February 17, 2018, 05:31:51 pm »
Source code attached. Any response is welcome.
1. In win32 compiler warning about "ss", "se" and "iMouseSelect": Mixing signed expressions and longwords gives a 64bit result. Change it (ss and se) to Integer.
2. Since you implement "Nothing is selected at activation", for the first time after starting, if you select any text in the combobox (with the mouse) and move the focus to another control (with the mouse), the selected text remains (.SelLength := 0 in WM_KILLFOCUS not work, because in EM_SETSEL skipped by .bAllow_EM_SETSEL = False).
3. Behavior differs from TEdit. If in TEdit the text (for example all) is selected, then when you return the focus using the mouse (poke in the middle), there is no selection. But for Combobox remains (from the point of hit to the end).

Is it necessary to output cbi to the public section. Maybe the "internal kitchen" will be in the private section?

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus