cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
0 Kudos

Scroll Box to support the << Scroll Window() command

Just as the title says, it'd be nice if the Scroll Box() supported the << Scroll Window() command.  Key advantage is being able to put in a DisplayBox and have the Scroll Box go straight to it.

1 Comment

This can be accomplished with a combination of <<Get Offset and <<Set Scroll Position. If the box being scrolled to is nested in the display tree, multiple calls to <<Get Offset (adding up the sum of offsets) will be needed on each parent up to the scroll box container. Below is an example where the box is just one level deep in the scroll box.

New Window("scroll to offset example",
	sb = V Scroll Box(size(100), vlb = v list box()),
	button box("Scroll to Important stuff",
		<<set function(function({this},
			offset = tb << get offset();
			show(offset);
			sb << set scroll position(offset[1], offset[2])
		))
	)
);

append = Function({vlb, n, text},
	{i},
	for( i = 1, i <= n, i++,
		vlb << Append(text box(text))
	);
);
// append some boxes
append(vlb, 10, "placeholder");
vlb << append(tb = text box("important stuff"));
append(vlb, 10, "placeholder");

However, a new message for scrolling to a box might be useful, so we have sent this suggestion to our development team for review.