Re: GTKCombo: autocomplete?



On Thu, May 13, 2004 at 14:09:18 +1000, Daniel Kasak wrote:
Hi all.

I realise that this is not strictly a PerlGTK questions, but maybe 
someone knows anyway.
I've got a GTKCombo box that I'm loading data into with 
$mycombo->set_popdown_strings(@list_of_companies).
The combo box will contain a list of all of our clients - it's a pretty 
large list.
Is it possible to have the combo box seek the closest match to what you 
type in the entry box ( yeah, like Access ).
It would make things a lot faster for the girl doing the data entry - 
who doesn't have this form yet, but will complain loudly when she gets it.

If this is not possible, are there any alternatives?

To show I've thought a little about this ... I suppose I could run some 
code each time a character is added / deleted from the entry box that 
matches the current text against @list_of_companies and updates the 
combo box accordingly. Would I use a loop and a regex expression to test 
each value and dump each string that matches in another array, and then 
finally dump this array into the combo box? Or something like that?

Yes, you can. The GtkCombo contains a GtkEntry and GtkEntry has
'insert-text' and 'delete-text' signals. There are also some facilities
in Gtk to do completions, which should be faster than regexps (after
all, C is still faster than perl). Actualy, it should be filed as Gtk
bug if GtkCombo does not do autocompletion automaticaly.

-------------------------------------------------------------------------------
                                                 Jan 'Bulb' Hudec <bulb ucw cz>

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]