Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Autocomplete TEdit
Mon, Mar 21 2016 6:53 AMPermanent Link

Luk

Hi,

Is it easy to add an autocomplete option like shown in https://jqueryui.com/autocomplete/ to the TEdit component ? An example how to do something similar would be very welcome Smile

Thanks.
Mon, Mar 21 2016 7:24 AMPermanent Link

Matthew Jones

Luk wrote:

> Is it easy to add an autocomplete option like shown in
> https://jqueryui.com/autocomplete/ to the TEdit component ? An
> example how to do something similar would be very welcome Smile

Shouldn't be too hard. Key is to detect the change using the normal
event, and then do whatever the lookup you are wanting and display the
results. Typically this will be a server call, so asynchronous. I'd say
the harder part would be to detect the key up/down to do the selection
in the list, but not impossible certainly.

--

Matthew Jones
Tue, Mar 22 2016 10:19 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Luk,

<< Is it easy to add an autocomplete option like shown in https://jqueryui.com/autocomplete/ to the TEdit component ? An example how to do something similar would be very welcome Smile >>

You wouldn't want to use the TEdit control as the starting point.  If you look in the WebEdits unit, you can see how this is fairly trivial using the TEditComboBox or TEditComboControl as the ancestor class.  You would just need a timer to detect when X milliseconds have elapsed without a keystroke, and then fire off a TServerRequest to get the list of items that you want to populate in the Items property.  Then you can call DoDropDown (protected method) to display the drop down list.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Mar 24 2016 8:35 AMPermanent Link

Luk

I would use the TStringList to show all the items. When the user starts typing, I would like to reduce the list to show only items containing the text the user typed.

In javascript, I found the function: search

Do I need to add this function as an external function ? Or can I use an internal function to do this ? Or should I write my own search function ?

Trying to create my first component ...

Thanks
Mon, Mar 28 2016 1:30 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Luk,

<< I would use the TStringList to show all the items. When the user starts typing, I would like to reduce the list to show only items containing the text the user typed.

In javascript, I found the function: search

Do I need to add this function as an external function ? Or can I use an internal function to do this ? Or should I write my own search function ? >>

You cannot mix JavaScript code into a visual control.  You must use Object Pascal to create such a control, otherwise you're introducing dependencies that can break anyone's application that uses the control.

If you aren't familiar with component/control development, especially in Delphi, then you may have some trouble trying to do something like this with EWB.

Tim Young
Elevate Software
www.elevatesoft.com
Image