Recent

Author Topic: Completion for a TEdit  (Read 2324 times)

FRex

  • New Member
  • *
  • Posts: 20
Completion for a TEdit
« on: October 19, 2017, 12:59:28 am »
I need to create live completion (like you get in code editors) for a TEdit. I'd make it myself, based on content of that TEdit. Right now I use a read only memo that is just below the TEdit but it comes with problems, you can't press down key to go into that list to pick from it, it goes off screen if the list is long, etc.

Is there a convenient way to get some sort of completion list to a TEdit or similar widget that has completion? I'd not want to put a 1 line TSynEdit there, that seems too silly and hacky.
App to keep track of notes in a single plain text file tagged by hashtags: https://github.com/FRex/botes

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: Completion for a TEdit
« Reply #1 on: October 19, 2017, 03:43:29 am »
TComboBox is basically what you are after.
 
It comes with a TEdit and a drop down  list that does not get covered.

You'll need to work the code in.
The only true wisdom is knowing you know nothing

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Completion for a TEdit
« Reply #2 on: October 19, 2017, 03:55:14 am »
you can see an example with list boxes (not memo) at https://github.com/taazz/Turbobird/blob/master/trunk/Frames/ufrfonteditor.pas there are a couple of pairs in that frame that do the same thing in short there are 3 events of interest in the tedit you have the onchage event and the onkeydown and on the list box you have the onselectionchange.
You can replace the listbox, if you do not want the visual list/clatter etc, with a stringlist and you are set.
« Last Edit: October 19, 2017, 04:11:54 am by taazz »
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

FRex

  • New Member
  • *
  • Posts: 20
Re: Completion for a TEdit
« Reply #3 on: October 19, 2017, 05:25:15 pm »
TComboBox was very similar to what I wanted but sometimes got in my way. In the end I replaced my TMemo by a TListBox to allow going through it with arrow keys and then handle few keys in OnKeyDown event to fill the original TEdit back. The TListBox is still filled when TEdit changes, just like TMemo was. If someone is really interested there is a link in my forum signature to the project (Botes) I'm doing this all for.
App to keep track of notes in a single plain text file tagged by hashtags: https://github.com/FRex/botes

 

TinyPortal © 2005-2018