Scrollbar Messaging?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Scrollbar Messaging?

Jim Rosenberg
Let's say I have a Workspace open on the contents of a file. I have an
"external" morph that I want to have programmatically operate the scrollbar
of the workspace by "remote control". If anybody happens to know just what
message should be sent to what target to e.g. scroll the workspace down by
a page I'd be much obliged for a hint of what class to browse to find this.

I thought it would be simple, but it looks like this could get tricky.

-Thanks, Jim

Reply | Threaded
Open this post in threaded view
|

Re: Scrollbar Messaging?

Doug Way

On Aug 7, 2006, at 9:10 PM, Jim Rosenberg wrote:

> Let's say I have a Workspace open on the contents of a file. I have  
> an "external" morph that I want to have programmatically operate  
> the scrollbar of the workspace by "remote control". If anybody  
> happens to know just what message should be sent to what target to  
> e.g. scroll the workspace down by a page I'd be much obliged for a  
> hint of what class to browse to find this.
>
> I thought it would be simple, but it looks like this could get tricky.

To help figure this out, I would start with your sample Workspace  
open on the contents of a file.  Brig up the morph halos (cmd/alt-
click) on the Workspace window and choose "explore morph" from the  
debug halo (the wrench).

You're now exploring the SystemWindow morph.  Start drilling down  
until you find the best way to get to the scrollbar object for the  
window.  One way is to go through the submorphs instvars, and there  
are other ways.  Anyway, for one example, under SystemWindow-
 >submorphs->a PluggableTextMorph->scrollBar you'll see a ScrollBar  
object.  Select this line, and then try performing some do-its in the  
space at the bottom of the explorer.

If you browse ScrollBar in a browser, you'll see some promising  
methods under the "scrolling" category, such as #scrollDown.  So back  
in the explorer, try "self scrollDown".  ("self" in this case is the  
ScrollBar object, since you've selected that object in the  
explorer.)  You'll see the workspace start to scroll, and never  
stop!  So, try some other methods on ScrollBar. :-)

Now to do this programatically, you just need to figure out how to  
best get to this scrollbar from your "external" morph.  You'll need  
to get to the Workspace object or SystemWindow first.  (Worst case,  
the World global (representing the morphic world) will have the  
SystemWindow for your workspace as one of its submorphs.)  Then find  
the appropriate accessors on the objects to get down to the scrollbar  
like you did through the explorer.  Then start sendin' messages to  
the scrollbar such as #scrollDown. :)

Hope that helps,

- Doug