From: MENON Jean-Francois Date: 2002-08-27T18:16:22+09:00 Subject: Re: Tk scrollbar with elided text Albert Wagner wrote: > > I am using a TkText as a base for an editor, with folding implemented by using > TkTags with the 'elide' option. However, the vertical scrollbar behaviour is > not what I expected. The slider within the scroller changes size depending > on whether elided text is or is not within the window. > For example: > I have several blocks of text, each block consisting of a header line that is > always visible and any number of body lines tagged so that they may be elided > as a group. > > If no bodies are elided, then the scrollbar works as expected. > > If all bodies are elided, then the scrollbar moves slowly as if it is actually > scrolling the elided lines and the slider changes size depending on whether a > small number or large number of elided lines are within the window. > > If there is a mix of blocks, with some bodies elided and some not, then the > slider changes both size and speed depending on whether the bodies within the > window or elided or not. > > I know that this must sound confusing. But perhaps some Tk user has > encountered this before. Here is my definition: > > #------------------------------------- > # Define Vertical Scrollbar > @vbar = TkScrollbar.new(parent, > 'orient' => 'vertical', > 'command' => proc{|*args|@doc.yview(*args)} > ).grid( > 'in' => @bigGrid, > 'padx' => 1, > 'pady' => 1, > 'row' => 0, > 'col' => 2, > 'rowspan' => 1, > 'columnspan'=> 1, > 'sticky' => 'news' > ) > > # synchronize @doc and @lineDoc to use same scrollbar > @doc.yscrollcommand(proc{|first, last| > @vbar.set(first, last) > @lineDoc.yview('moveto', first)} > ) > # @doc is the main TkText and @lineDoc is a slave TkText containing line > numbers. maybe you should not use the standard 'yview' command of TkText, but implement your own function to calculate the good 'first' and 'last' values ? jf -- _________________________________________ / do you play Go? \ |http://jeanfrancois.menon.free.fr/rubygo | \ / ----------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||