Subscribe Bookmark RSS Feed

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

mikedriscoll

Community Trekker

Joined:

Jun 23, 2011

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
Justin_Chilton

Joined:

Aug 27, 2015

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

Community Trekker

Joined:

Jun 23, 2011

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

Community Trekker

Joined:

Jun 23, 2011

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

Justin_Chilton

Joined:

Aug 27, 2015

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

Community Trekker

Joined:

Jun 23, 2011

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

Justin_Chilton

Joined:

Aug 27, 2015

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