Tuesday, May 25, 2010

gnocl::entry new feature : word completion

Well, added a nice new feature to the gnocl::entry today – word completion. Whilst the manual pages on the topic is somewhat complex, and the whole completion contexts is a widget, the implementation is simply an ‘ attachment’ made to the GtkEntry on initialization. The wordlist by default is empty, and so items need adding to it. Here’s the test-script:

# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl

set ent1 [gnocl::entry ]
gnocl::window -child $ent1

# simple alpha validation
$ent1 configure -onKeyPress {
    if {![string is alpha %K] } {
        gnocl::signalStop %w %e

# press return
$ent1 configure -onActivate {
    puts %t

# add some items to the completion wordlist
$ent1 wordList add [list red orange yellow green blue indigo violet]


No comments: