cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
MarkJohnson
Level II

How to set scroll position for list boxes

I am getting Object 'ListBoxBox' does not recognize the message 'get scroll position' errors when trying to set the scroll location for a list box.

 

My script automatically selects a value from the list, but if that value is not currently visible, it looks like the list box has no selection. It would be good for me if I could get it to scroll down to make sure the user doesn't get confused by this. I've been looking at the Set Scroll Position documentation.

 

Does anyone know how to do this? Thanks!

 

Names Default To Here( 1 );
listOfItems = {};
for (i = 1, i <= 30, i++,
	insert into(listOfItems,"Item " || char(i));
);

New Window( "Example",
	fontobj = lb = List Box(
		listOfItems,
		width( 200 ),
		max selected( 2 ),
		nlines( 6 )
	)
);

lb << set selected(7);

//lb << somehow scroll down to make position 7 visible!
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to set scroll position for list boxes

Neither the ListBox() or the ListBoxBox() objects accept scroll position messages.  Those messages work with ScrollBox();  See the example below, and read about it in the Scripting Guide

win = New Window( "Example",
sb = Scroll Box(
Size( 150, 75 ),
List Box(
{"First Item", "Second Item",
"Third Item", "Fourth Item",
"Fifth Item"},
width( 200 ),
max selected( 2 ),
nlines( 6 )
)
)
);
win << Set Window Size( 300, 200 );
sb << Set Scrollers( 1, 1 ); // enable both scroll bars
sb << Set Scroll Position( 0, 10 ); /* position the scrollers on

 

Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: How to set scroll position for list boxes

Neither the ListBox() or the ListBoxBox() objects accept scroll position messages.  Those messages work with ScrollBox();  See the example below, and read about it in the Scripting Guide

win = New Window( "Example",
sb = Scroll Box(
Size( 150, 75 ),
List Box(
{"First Item", "Second Item",
"Third Item", "Fourth Item",
"Fifth Item"},
width( 200 ),
max selected( 2 ),
nlines( 6 )
)
)
);
win << Set Window Size( 300, 200 );
sb << Set Scrollers( 1, 1 ); // enable both scroll bars
sb << Set Scroll Position( 0, 10 ); /* position the scrollers on

 

Jim