Re: validation with JCombobox

Rob Seegel <[email protected]>
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
[email protected] wrote:

> I have a problem recreating a standard Windows behaviour for drop-down
> lists: User can type in an entry, as long as those letters match the
> beginning of a list entry, the list entry is highlighted. When a letter is
> entered that doesn't match anymore, nothing in the list is selected, i.e. it
> is a "free entry". 

Ok, I've been working on a new release, and decided to thoroughly scrub 
the entire module, fixing whatever problems I can find and addressing 
any problems that have been sent to the mailing list/c.l.p.tk over the
past year or so. I think I have a solution to your problem. I've never 
been completely happy with the -validate option. It seemed like I was
mixing two different pieces of functionality together (finding existing 
entries in the Listbox, and validating what can be set in the
Entry widget (or Label in RO mode). So in the new version, I've 
separated these two. There is still a validate mode called match/csmatch 
  in addition to the other modes that can be set for an Entry widget. 
These modes are for validation purposes only and do not cause the 
Listbox to be displayed. What's more, the validate option has no effect 
at all when the JComboBox is in readonly mode.

There is a new option called -autofind that takes a reference to a hash
containing one or more options that define the autofind behavior. The
autofind options include:

-enabled  => boolean (defaults to true/1)
      whether or not autofind feature is activated or not

-casesensitive => boolean  (defaults to false/0)
      whether or not the case of the entry matters in finding a match

-completion => boolean (defaults to false/0)
      whether or not to use autocompletion within the Entry similar to
      what web browsers do within their location bar.

-showpopup => boolean (defaults to true/1)
      whether or not to display the listbox while using autofind
      functionality.

The effect the options have will depend on what mode the JComboBox is 
in. In readonly mode, the only options that will have a noticeable 
affect will be: -enabled and -showpopup, -casesensitive and the default 
behavior will be like what is found on windows machines. The initial 
letter will be able to be used to jump through the selections beginning 
with that letter. I believe this default behavior is what you are 
looking for.

In editable mode, all of the above options will be able to be used, and 
the default behavior will be similar to the older version of JComboBox 
when the -validate option was set to match. The main difference is that 
now the Combo Box will not prevent entries from being entered that are 
not contained within the Listbox so long as -validate is not set to
match or cs-match.

This, along with a few other tweaks should bring JComboBox in line with
the majority of the features offered by any of the other Combo Box 
widgets. The new version is about 2/3 complete, but I won't be releasing
it until it has test cases, revised documentation, including a POD 
version of it. Except for bug-fixes, this may be the last release of 
JComboBox as a stand-alone module. Future releases will likely have
dependancies on other Tk modules I'm working on, so it will just be 
easier to bundle them together. Easier for me to manage, and easier for
folks to download so that they do not have to track down invidual
dependancies.

Rob


-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.