Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrollbar Slider size?

Status
Not open for further replies.

voxlumania

Programmer
Jul 6, 2001
1
US
I was wondering if anybody knew a way to set the minimum slider size of a scrollbar. If I fill a listbox with a lot of information, the slider gets real small. I'd like to increase it.

Thanks in advance,
Bill
 
If you're ready to code the hack, here are some hints.

0/ The initial script:
Code:
  listbox .lb -yscroll { .sb set }
  scrollbar .sb -command { .lb yview }

1/ How scrollbar -command and listbox -yscrollcommand interact:

1.a: When the listbox resizes, the command [.sb set $beg $end] is executed by the listbox.
$beg is the fraction (between 0.0 and 1.0) where the visible area starts.
$end is the fraction (between 0.0 and 1.0) where the visible area ends.
These two fractions command the display of the slider: its position and its size.
For example [.sb set 0.25 0.75] will set a slider that begins at 25% of the height and ends at 75% of the height, occupying 50% of the height.

1.b: When the user click inside the scrollbar, the scrollbar generate some command beginning with [.lb yview...].
The scroll or the moveto subcommands are used depending of the part of the scrollbar that was hitted.

2/ What do you can do?
You can intercept the set command generated by the listbox to magnify the slider.
Try this:
Code:
  set ::list { a b c d e f g h i j k l m n o p}
  listbox .lb -yscroll yscroll -list ::list
  scrollbar .sb -command { .lb yview }
  pack .lb .sb -side left -fill y
  proc yscroll {beg end}   {
    set beg [expr {$beg * 0.5}]
    set end [expr {$end * 0.5}]
    .sb set $beg $end
  }
You'll see the slider magnified but scrolling had became erratic. This later because the start of the slider is not in sync with the listbox.
If you experiment and obtain what you wanted, let me know.

Good luck

ulis

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top