Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-04

Making a auto-complete dropdown list

6 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Yan Chengyuan

Hi,all!
Recently i've been working on a mess: making my own dropdown list,which (i wish) has the following characteristics:

*Sort the items according to their LCS(Longest Common Subsequence) with the text
*auto-complete
*response to some specified key-press event

firstly i created a form called "DropDownForm",put a ListBox on it. on another form i put a Tedit.when the text is changed,i'll sort the items of the ListBox,set the dropdownform's position,and make it appear. but i've been faced with this fact:when the dropdownform is shown,the TEdit losts its focus,even if i wrote"Edit1.SetFocus".So that when i type something, what changed is not the text of the TEdit, but the ListBox instead. and that makes it impossible to implement the sort-while-typing function.

Can anyone help me?Thanks in advance.

Regards,
Yan Chengyuan

Reply by email

Bart
to Yan Chengyuan

Hi,

If you try to do this cross-platform, you might run into this bug: http://bugs.freepascal.org/view.php?id=7243

I have an app with autocompletion TEdit. When it finds a match it appends the part that was not typed in yet, and selects that part in the control.
This works perfectly well in win32, but in GTK the SelLength property is not updated correctly in the TEdit.OnChage event. I was never able to pinpoint where this goes wrong and no other Lazarus users seem to need this specific behaviour it seems.

Bart

Reply by email

闫程远
to Bart

nonono,i didn't mean that. i was considering why the inputbox TEdit losts its focus,even if i "setfocus".
the lost of focus make me mad because when the dropdownform is shown,i have to click the TEdit and begin typing again and again.

2009/4/26 Bart

Show quoted text 19 lines
Hi, If you try to do this cross-platform, you might run into this bug: http://bugs.freepascal.org/view.php?id=7243 I have an app with autocompletion TEdit. When it finds a match it appends the part that was not typed in yet, and selects that part in the control. This works perfectly well in win32, but in GTK the SelLength property is not updated correctly in the TEdit.OnChage event. I was never able to pinpoint where this goes wrong and no other Lazarus users seem to need this specific behaviour it seems. Bart _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
I'm sure that I will win. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090426/64e87537/attachment.html

Reply by email

Flávio Etrusco
to Yan Chengyuan: Hi,all! Recently i've been working on a mess: making my own dropdown list,which (i wish)…
Yan Chengyuan wrote 23 lines
Hi,all! Recently i've been working on a mess: making my own dropdown list,which (i wish) has the following characteristics: *Sort the items according to their LCS(Longest Common Subsequence) with the text *auto-complete *response to some specified key-press event firstly i created a form called "DropDownForm",put a ListBox on it. on another form i put a Tedit.when the text is changed,i'll sort the items of the ListBox,set the dropdownform's position,and make it appear. but i've been faced with this fact:when the dropdownform is shown,the TEdit losts its focus,even if i wrote"Edit1.SetFocus".So that when i type something, what changed is not the text of the TEdit, but the ListBox instead. and that makes it impossible to implement the sort-while-typing function. Can anyone help me?Thanks in advance. Regards, Yan Chengyuan

What widgetset and what Lazarus version are you using? With latest Lazarus svn on Windows this works without a problem.

Best regards,
Fl?vio

Reply by email

Hans-Peter Diettrich
to 闫程远: nonono,i didn't mean that. i was considering why the inputbox TEdit losts its focus,even…
nonono,i didn't mean that. i was considering why the inputbox TEdit losts its focus,even if i "setfocus". the lost of focus make me mad because when the dropdownform is shown,i have to click the TEdit and begin typing again and again.

Untested: Try to make the old *form* Active, because only the active form (or a component on it) can receive the focus. If this helps, it's worth further investigations WRT platform compatibility.

DoDi

Reply by email

闫程远
to Hans-Peter Diettrich

I'm using lazarus 0.9.26.the "bug" occurs only when my project is compiled with GTK2.it's much better (though not perfect) with GTK1.

Show quoted text 5 lines
Untested: Try to make the old *form* Active, because only the active form (or a component on it) can receive the focus. If this helps, it's worth further investigations WRT platform compatibility.

i've tried this ,but it didn't work.maybe i used it wrongly?

I'm sure that I will win. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090427/a0fdd20c/attachment.html

Reply by email