# select everything
$lb->selectionSet(0, 'end' );
But, you only want to do this if no entry is selected.
@selected = $lb->curselection;
unless (@selected) {
$lb->selectionSet(0, 'end' );
}
foreach (@selected) {
# do something with the index in $_
}
Untested!
SciDude
The first dog barks... all other dogs bark at the first dog.
| [reply] [d/l] [select] |
selectionSet(0, 'end' ); dint seem to work it gives me an error entry end not found
| [reply] |
$listbox->index(index)
Returns the integer index value that corresponds to index. If inde
+x is end the return value is a count of the number of elements in the
+ listbox (not the index of the last element).
Really, really untested code. Good luck!
SciDude
The first dog barks... all other dogs bark at the first dog.
| [reply] [d/l] |
To get the last element, something like this could work (untested code!):
$last_entry = ($hlist->info("children"))[-1];
| [reply] [d/l] |
There is something to watch out for in HList selections. There is an "internal counter in HList" which increments the selection number of the list children. For instance, if you have 10 list entries, their list numbers will be 0-9. If you delete them, and make 10 new entries, the last entry number will now be 19. So you have to test for the existence of the selection.
For example, I wanted to delete an entry, and then have the active selection move to the next entry. If the next entry dosn't exist, go to the previous entry.Well you may have already deleted the "previous internal number" and you will get "entry dosn't exist" if you just try to go to the previous(or next) number. So you need something along the line of this sub. It just gives you the idea.
sub{my $listnum =$h->info('selection');
$h->delete('entry',$h->info('selection'
+));
if($h->info('exists', $listnum + 1))
+{
$h->selectionSet($listnum + 1)
}else{
while($listnum--){
if($h->info('exists',$
+listnum)){
$h->selectionSet($
+listnum);last}
}
}
delete $info{$key_sel};
I'm not really a human, but I play one on earth.
flash japh
| [reply] [d/l] |