Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Populating a Drop Down List at Runtime
Fri, Oct 9 2015 12:17 AMPermanent Link

Richard Harding

Wise Nutrition Coaching

I wish to populate a Drop Down list at runtime.  I have added code to the OnDropDownShow event of a TEditComboBox control that adds items to the control's Items property.

For example,

procedure TfmStockDetail.cbTypeDropDownShow(Sender: TObject);
begin
  TEditComboBox(Sender).Items.Clear;
  TEditComboBox(Sender).Items.Add('One');
  TEditComboBox(Sender).Items.Add('Two');
  TEditComboBox(Sender).Items.Add('Three');
end;

The first time I click the Button to drop down the list, the list is empty.  I need to click on the button 2 or 3 times before the items appear in the list.  Can someone suggest a better way of handling this?

Also, if I press the Escape key to close the list, the selected item is shown in the control instead of the original value.

Thank you . .

Richard Harding
Fri, Oct 9 2015 12:41 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< The first time I click the Button to drop down the list, the list is empty.  I need to click on the button 2 or 3 times before the items appear in the list.  Can someone suggest a better way of handling this? >>

I've fixed this for 2.02 - it's just the ordering of the event fire vs. the population of the drop-down list.

<< Also, if I press the Escape key to close the list, the selected item is shown in the control instead of the original value. >>

This is as-designed.  As you navigate the drop-down, the edit control is updated.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Oct 9 2015 7:20 PMPermanent Link

Richard Harding

Wise Nutrition Coaching

<<I've fixed this for 2.02 - it's just the ordering of the event fire vs. the population of the drop-down list.>>

Great - thanks Tim.


<<This is as-designed.  As you navigate the drop-down, the edit control is updated.>>

The drop down controls I use to develop applications use the Escape key to revert the item to the original value.  I assumed it was standard behaviour - but no. My applications are the only ones I can find that revert back to the original value on pressing Escape.

Richard Harding
Sat, Oct 10 2015 12:21 AMPermanent Link

Raul

Team Elevate Team Elevate

On 10/9/2015 7:20 PM, Richard Harding wrote:
> The drop down controls I use to develop applications use the Escape key to revert the item to the original value.  I assumed it was standard behaviour - but no. My applications are the only ones I can find that revert back to the original value on pressing Escape.

Curious - how exactly are you navigating the drop down list ?

Quick test of web based drop down lists work same as EWB :

- if you open the drop list with mouse then it tracks selection with
mouse but does not select anything until you click on an item

- if you open list with mouse but navigate with cursor keys then
selection is changed each time you navigate and escape has no effect

- navigating with cursor keys does not open list but changes selection

Raul
Sun, Oct 11 2015 3:39 PMPermanent Link

Richard Harding

Wise Nutrition Coaching

Hi Raul,

Yes, as  far as I can see, all web based applications including EWB applications work as you describe.

However, with my PC applications, irrespective of whether the item in the list is selected or tracked, the value of the control reverts back to the original value, if the user presses the Escape key before the control loses focus.  So does Microsoft Office and Open Office applications.

For example, in Microsoft Word, if you scroll down the font list, it will change the font name in the Font Text box but pressing Escape reverts the font back to the original value. Other drop down lists in these applications do the same.

If you press the Escape key whilst you are in a TEdit control, then it returns to the original value.  To me, it is the same concept.

Richard
Tue, Oct 13 2015 8:48 AMPermanent Link

Raul

Team Elevate Team Elevate

On 10/11/2015 3:39 PM, Richard Harding wrote:
> Yes, as  far as I can see, all web based applications including EWB applications work as you describe.
> However, with my PC applications, irrespective of whether the item in the list is selected or tracked, the value of the control reverts back to the original value, if the user presses the Escape key before the control loses focus.  So does Microsoft Office and Open Office applications.

Not seeing it here with standard delphi TCombobox - in my case it
behaves just like EWB combo (as per my previous posting) and escape does
not really have any effect nor revert anything.


> For example, in Microsoft Word, if you scroll down the font list, it will change the font name in the Font Text box but pressing Escape reverts the font back to the original value. Other drop down lists in these applications do the same.

That one is a very special one and likely has tons of code underneath to
handle this  - in my case at least it does a "Live preview" of the font
in the document also.

Raul
Tue, Oct 13 2015 4:54 PMPermanent Link

Richard Harding

Wise Nutrition Coaching

> For example, in Microsoft Word, if you scroll down the font list, it will change the font name in the Font Text box but pressing Escape reverts the font back to the original value. Other drop down lists in these applications do the same.

That one is a very special one and likely has tons of code underneath to handle this  - in my case at least it does a "Live preview" of the font in the document also.>>

Hi Raul

Yes - the font drop down list was not a good example.  However, EVERY drop down box in Microsoft Office Options uses the Escape key to revert the option back to the original value.  So does EVERY drop down box in Open Office options.

But NOT Notepad ++.  As you pointed out, this is the behaviour of the standard TCombobox control.  I was not aware of this and expected the escape key to respond differently.

Richard
Image