Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » AutoScroll
AutoScroll [message #439045] Mon, 05 July 2004 19:27 Go to next message
Tobias Weih is currently offline Tobias WeihFriend
Messages: 24
Registered: July 2009
Junior Member
hi,

assume you have a ScrollPane populated with a number of Widgets.
When traversing through them using the keyboard, I want the
ScrollPane to shift the visible rect, so the user always sees
the widget that has the focus.

any ideas how to approach this?

tobi
Re: AutoScroll [message #439111 is a reply to message #439045] Tue, 06 July 2004 04:38 Go to previous message
Ryan is currently offline RyanFriend
Messages: 34
Registered: July 2009
Member
Hi Tobi,

I was trying to do the exact same thing. Assuming you have all your
widgets in a single column (i.e. you will only traverse them using the
up/down arrow keys), try calling this method every time you press the
up/down arrow keys.

/*
* temp is the widget that has focus after the up/down key is pressed
* e indicates whether up or down was pressed
* sc is the ScrolledComposite
*/

void scrollContents(Widget temp, int e)
{

if (e == SWT.ARROW_DOWN)
{
Point pt = temp.getLocation();
Rectangle rect = sc.getClientArea();
Point widget = temp.getSize();
sc.setOrigin(temp.getLocation().x, pt.y - (rect.height - widget.y));
}
else if (e == SWT.ARROW_UP) sc.setOrigin(temp.getLocation());

}

Hope this helps!

Ryan






Tobias Weih wrote:

> hi,

> assume you have a ScrollPane populated with a number of Widgets.
> When traversing through them using the keyboard, I want the
> ScrollPane to shift the visible rect, so the user always sees
> the widget that has the focus.

> any ideas how to approach this?

> tobi
Previous Topic:Debug OSX blat.app tree SWT app?
Next Topic:swt 3.0 gtk bug: table header disappearing
Goto Forum:
  


Current Time: Wed Sep 25 17:32:33 GMT 2024

Powered by FUDForum. Page generated in 0.04471 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top