cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMPĀ® Marketplace
Choose Language Hide Translation Bar
mikedriscoll
Level VI

Is it possible to add a horizontal scroll bar to listboxbox?

Hi, Is it possible to add a horizontal scroll bar to listboxbox? To be clear, it is a listbox(), not a col list box().

 

Ex:

names default to here(1);
myList ={};
for(i = 1, i <= 10, i++,
	myList[i] = char(i) || "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz";
	
);

myWin = new window("test", lb = listbox(myList,nlines(7), width(250)));

 

Thanks,

Mike

6 REPLIES 6

Re: Is it possible to add a horizontal scroll bar to listboxbox?

There does not appear to be a way to get horizontal scrollbars within a ListBoxBox. You can send an email to us, if you would like, at support@jmp.com and we can submit a suggestion to our development team for review.

You could use an H Scroll Bar around of your List Box, but there would be some odd behavior and you would need to set a wide width for the LIst Box. 

A simpler option might be to add tips to each item in the List Box so that if the item is wider than the available space, you can view the content as a tooltip. Below is an example script of how to do this using the Set Tip message.

Names Default To Here( 1 );
myList = {};
For( i = 1, i <= 10, i++,
	myList[i] = Char( i ) ||
	Repeat( "_abcdefghijklmnopqrstuvwxyz", 3 );
	
);

myWin = New Window( "test",
	lb = List Box(
		myList,
		nlines( 7 ),
		width( 250 ),
		<<set tips( myList )
	)
);
Justin
mikedriscoll
Level VI

Re: Is it possible to add a horizontal scroll bar to listboxbox?

Thanks Justin. Actually I just found a workaround that seems to work pretty well. I embed the listbox into a scroll box, set the width of the list box nice and wide, and the width of the scrollbox as narrow as I need.

 

The reason I want to do it this way is because in my actual script, I have two associated columns, basically two different names for the same parameters. Some people care about 1 name (up to 32 characters); other people care about the other name, which can be many characters. So I concatenate the first name || "_::" || second name. #of underscores is 32 minus the length of the first name, to try to align them in the box. 

 

Here's the updated test script with the scroll box:

 

names default to here(1);
myList ={};
for(i = 1, i <= 10, i++,
	myList[i] = char(i) || "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz";
	
);

myWin = new window("test", 

	sb = Scroll Box(
		Size( 200, 400 ),
		lb = listbox(myList,nlines(7), width(600))
	);

);
sb << Set Scrollers( 1, 1 ); // enable both scroll bars
mikedriscoll
Level VI

Re: Is it possible to add a horizontal scroll bar to listboxbox?

Somehow I skipped right over the part about the H Scroll Bar. Is that the same as scroll box?

Re: Is it possible to add a horizontal scroll bar to listboxbox?

H Scroll Box provides horizontal only scrolling, just as V Scroll Box provides vertical only scrolling. A regular Scroll Box provides horizontal and vertical Scrolling.
In case you are interested, the H Scroll Box(), V Scroll Box(), and Scroll Box() functions are constructors that all create the same DisplayBox[ScrollBox] object type. The difference is that the V/H Scroll Box functions automatically set the Scrollers property that you can set yourself using Set Scrollers (you can find more info about this message in the Scripting Index at Help > Scripting Index > ScrollBox > Set Scrollers).

Justin
mikedriscoll
Level VI

Re: Is it possible to add a horizontal scroll bar to listboxbox?

Thanks. I tested it a little more, and I see what you mean about the quirky behavior. I also need to set the nlines() in the list box as nlines(nitems(myList)) because otherwise vertical scrollbar in the listbox is only visible when viewing the right side of the scrollbox. But so far it seems pretty good.

 

-Mike

Re: Is it possible to add a horizontal scroll bar to listboxbox?

Yes, NLines(NItems(myList)) is exactly what I did when using the regular Scroll Box. This makes it so that you are in control of both scroll bars with the ScrollBox.
Justin