listbox Search by keyboard


I have a search system in a listbx where I need to clic one letter on keyboard (A, u, x, etc …) and listbox check out the first word that is this letter today I use a textfield to do this but in cocoa he loses focus frequently and I have to click it to find another letter, I would have to check for direct lyrics by listbox events or something ?

Listbox keydown
(this is for column 1)

  dim i, start as integer
  if me.listIndex > -1 then
    if left(me.Cell(me.listIndex, 1), 1) = key then
      start = me.listIndex + 1
      start = 0
      me.listIndex = -1
    end if
  end if
  for i = start to me.listcount - 1
    if left(me.Cell(i, 1), 1) = key then
      me.listindex = i
      return true
    end if
  return true

Hi Axel Schneider ,

I could not get results with your code, when I click on any button in the list is ListIndex = -1, which may be happening, do you have any suggestions?

Hi - rather than using a textfield to do this you could use my Filter Control which I just released yesterday! (free and unrestricted)

Filter Control - Thread

Patrick, Thanks I’ll download and try it now.

Do check the thread - there is a small issue with the test window rather than the control itself!


As an alternative, if your only working on Mac you may want to check out what Jim McKay has been working on. He’s just released a Filter Control made with Declares so you get the whole Mac native thing going on.

Choice is a good thing - right :slight_smile:

NSSearchField - Thread

Tanks Patrick Delaney for your attention !