jdtoronto has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed monks,

I have a JBrowseEntry being used to select one possible option from a list at the moment. Client has asked for multiple selection capability. Is there an existing 'one-piece' widget that does this or do I need to roll my own?

jdtoronto

Replies are listed 'Best First'.
Re: TK: Multiple selection needed.
by Tanktalus (Canon) on Aug 12, 2005 at 20:25 UTC

    jdtoronto,

    Given the overwhelming response you've gotten so far ;-), I'd like to ask if you have a minimal set of working code of what you've tried - because then I may be able to take it and tweak it. Note that I have absolutely zero Tk experience, and the last time I did any GUI work was Delphi on a Win95 beta, and, before that, Win32 SDK (without MFC or anything helpful). And I've not done any Windows programming since '96. :-) But I might be able to tweak something that someone gives as an example.

    Oh, and I think you mean Tk::BrowseEntry, and not JBrowseEntry, right?

Re: TK: Multiple selection needed.
by Anonymous Monk on Aug 14, 2005 at 07:25 UTC

    As much as I hate to say it, selecting multiple items from a List is generally NOT a good use of a Combo Box type widget -- especially since most trigger a selection instantly after the first item is selected. Is there a reason that this has to be a Combo Box (or Tk::JBrowseEntry to be precise)? I believe that none of the current Tk Combo Box type widgets provide the functionality that you are looking for.

    One of the problems is how is the Entry supposed to display the results of a multiple selection? Comma-separated words? What happens if one of the items in the list contains a comma or whatever delimiter you plan on using?

    Here are some alternatives:
    1. Just use a listbox. It already allows for multiple selection. Do you need user-defined entries? Try using using an entry and a button that adds entries to the Listbox. Too many widgets on Screen? Create a button underneath or above the Listbox that triggers a popup Entry to add a new item to the Listbox (pretty much the reverse of what is typically done with a combo box).

    2. Try using a Menu with CheckButtons if the list is fairly small and static.
Re: TK: Multiple selection needed.
by zentara (Cardinal) on Aug 14, 2005 at 13:51 UTC
    Well now that I got Tk::JBrowseEntry, the answer is right in the perldoc
    "but user may only ultimately select one of the items in the list"
    You would be better off rolling your own with a listbox.

    I'm not really a human, but I play one on earth. flash japh
Re: TK: Multiple selection needed.
by zentara (Cardinal) on Aug 13, 2005 at 10:34 UTC
    No documentation found for "Tk::JBrowseEntry".

    But I think you will have to roll your own. You could try to use the subwidget method, to get the Listbox out of your parent widget, and change it's selectmode to multiple, but there are alot of complications.....like most widgets have code to automatically insert the first selection at the first mouse click.


    I'm not really a human, but I play one on earth. flash japh
      http://search.cpan.org/~turnerjw/Tk-JFileDialog-1.21/Tk/JBrowseEntry.pm