Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!uc!shamash!caffeine!dtj From: dtj@caffeine.cray.com (Dean Johnson) Newsgroups: comp.windows.x Subject: Re: Controlling Viewport scrollbars. Message-ID: <7323@caffeine.cray.com> Date: 10 Jul 90 18:55:45 GMT References: Distribution: comp Organization: Cray Research Inc. - Mendota Heights, Minnesota Lines: 47 #include In article roy@neptune.iex.com (Roy Cantu) writes: > > The Viewport widget provides horizontal and vertical scrollbars to > control its child. I was wondering how the application may gain > control over these scrollbars. Looking at the Scrollbar widget, I see > that the user may set the callback function, specify the thumb position, > specify the length of the thump etc. > > Is it possible to gain such control over my Viewport scrollbars without > the hassle of implementing individual Scrollbar widgets? > > In particular, I would like to be notified when the user has moved > a scrollbar thumb and by how much. Furthermore, I would like > to be able to move the thumb and scroll the Viewport text from *within* > the application. > >Any suggestions are appreciated. Here is an example of how to move a viewport vertical scrollbar to the top. Please note that there is probably no *correct* way to do this, so be warned that children should use this only under parental supervision. (flames, etc. >& /dev/null) -Dean Johnson Tools, Libraries, and Commands Group Cray Research Inc. Mendota Heights, MN ------- cut here --------- ZeroViewportScroll(widget) ViewportWidget widget; { Widget v_bar; /* * It doesn't make any sense to zero a viewport that doesn't * currently exist. */ if (!XtIsRealized((Widget) widget)) return; v_bar = XtNameToWidget(widget,"vertical"); XtMoveWidget(widget->viewport.child,0,0); XtScrollBarSetThumb(v_bar,0.0,-1.0); }