in reply to Listbox keeping the selection in 1 listbox

It is no more the same carrot so you can't expect the listbox to "keep" the selection on "it".

You have to save somewhere the selection before changing the list contents and then restore it. How to do it is depending on what identifies an item being "the same" after the change. In the example you give, I would save the value (not the index) of the selected item(s) and the select again the items holding the same values.

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

  • Comment on Re: Listbox keeping the selection in 1 listbox

Replies are listed 'Best First'.
Re^2: Listbox keeping the selection in 1 listbox
by renegadex (Beadle) on Jul 12, 2008 at 13:15 UTC
    but how do i select that new item? i have tried to use $canvas->activate(1) but it doesn't highlight the item.. nothing seems to be working.. haaay...

      I never used Tk::Listbox so this is little more than a guess but, based on a cursory read of POD, I think that the methods you need are listbox->activate($index) that makes the element of index $index the current element and listbox->selectionSet($index,$index) that put the element $index in the selection set.

      Obviously you need to know the index of the element you want to activate, so you'll probably have to search for it in the listbox itself.

      Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."