I can see in my head how this *should* work... but I tried it in my project and it doesn't
On Thu, Oct 9, 2008 at 1:17 AM, Doriano Blengino <[EMAIL PROTECTED]> wrote: > M0E Lnx ha scritto: >> is there a way to code it in my key_release event? >> >> On Tue, Oct 7, 2008 at 4:53 PM, Benoit Minisini >> <[EMAIL PROTECTED]> wrote: >> >>> On mardi 07 octobre 2008, M0E Lnx wrote: >>> >>>> I have a really long list in a lisbox. I'd like to make it so when I >>>> press "s" on the keyboard, it jumps to the first item whose text >>>> starts with an "s" or any other letter for that matter. >>>> >>>> Can someone suggest a way to do this? >>>> >>>> >>> Yes, Qt does that by default, but not GTK+. Again, I need to implement that >>> feature in the gb.gtk component. >>> >>> > I don't know if the KeyRelease event is the right one to use (it seems > strange to me: why wait for a key release to do something? Normally > things happen as soon as a key is pressed...), but surely KeyPress can work. > > In the KeyPress event of the listbox, start to search for the next item > beginning with the letter, with wrap; then move the index. > In pseudocode: > > sub xxx_keypress() > dim scan as integer > > if key.text > "z" or key.text < " " then return ' this key is > not "searchable" > > scan = last.index > do > inc scan > if scan >= last.count then scan=0 ' wrap to the top again > if scan=last.index then return ' went where we started off: > didn't find another item > if last[scan].text like key.text & "*" then > ' found another > last.index = scan > return > loop > end sub > > I did not test this snippet but the general idea should work. May be > some adjustment is needed... > May be this is slow... > > Regards, > Doriano > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user