summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tk/scrollbar.rb
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-07 14:50:59 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-07 14:50:59 +0000
commitecc7210323f0877eb11933973649ac8a21f685d0 (patch)
tree3a373a3d4ba064609a8ad2c5c3a63898c7f92516 /ext/tk/lib/tk/scrollbar.rb
parente95d791e6236dcdd328bd547a937ac6a0f0bef00 (diff)
* ext/tk/lib/tk/scrollbar.rb: When 'set' operation, a scrollbar cannot
propagate view port information from the source widget (that calls 'set') to other assigned widgets. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tk/scrollbar.rb')
-rw-r--r--ext/tk/lib/tk/scrollbar.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/tk/lib/tk/scrollbar.rb b/ext/tk/lib/tk/scrollbar.rb
index 98b0247207..c6591a1270 100644
--- a/ext/tk/lib/tk/scrollbar.rb
+++ b/ext/tk/lib/tk/scrollbar.rb
@@ -29,6 +29,15 @@ class TkScrollbar<TkWindow
end
private :create_self
+ def propagate_set(src_win, first, last)
+ self.set(first, last)
+ if self.orient == 'horizontal'
+ @assigned.each{|w| w.xview('moveto', first) if w != src_win}
+ else # 'vertical'
+ @assigned.each{|w| w.yview('moveto', first) if w != src_win}
+ end
+ end
+
def assign(*wins)
begin
self.command(@scroll_proc) if self.cget('command').cmd != @scroll_proc
@@ -39,9 +48,9 @@ class TkScrollbar<TkWindow
wins.each{|w|
@assigned << w unless @assigned.index(w)
if orient == 'horizontal'
- w.xscrollcommand proc{|first, last| self.set(first, last)}
+ w.xscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
else # 'vertical'
- w.yscrollcommand proc{|first, last| self.set(first, last)}
+ w.yscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
end
}
Tk.update # avoid scrollbar trouble