I think, long time ago, at REALbasic release 1 or so, that when you have a one Column ListBox full of entries (starting with a letter), when you pressed a, you will get the first Row who text start with a “a” highlighted, same with b, 'till z just what the Finder does for us since ages
dim i, start as integer
if me.listIndex > -1 then
if left(me.Cell(me.listIndex, 0), 1) = key then
start = me.listIndex + 1
else
start = 0
me.listIndex = -1
end if
end if
for i = start to me.listcount - 1
if left(me.Cell(i, 0), 1) = key then
me.listindex = i
return true
exit
end if
next
return true
The first text file I loaded had numbers in Column 0 (the project I can really use it is in an external hard disk and I do not had time to get it, so I took the first found project that use ListBox !
So, I added a way to use the code on the selected Column and it works as advertised: it displays the Row that have the first u, and a nother attempt displau the next one, etc.
FWIW: I added in the main project a search module that allows me to search in the whole ListBox contents (and even in two or more columns if each text is separated with a \tab character )
Nice to code, surprising to use it (the multi column search was a surprise for me !).
a. Axels shared code:
In the SortColumn event of the ListBox, I set the Column to a global property (gSelCol) and I pass that to Me.Cell(me.listIndex, 0):
me.Cell(me.listIndex, gSelCol)
b. Search text inside a ListBox:
Imagine you have a Row that holds peoples personal info like:
Emile Schwarz Birth Date Address etc.
In the search routine, you pass “Emile Schwarz” as search string (the character between first name and family name is a tab).
When you type a letter into a popupmenu, it will by default search for the first instance of that letter and display the corresponding entry in the list. It sounds like the behavior you described. I’m wondering if you recalled that functionality, but thought it applied to a listbox instead of a popupmenu.