Notifications
Clear all

[Closed] Listbox height: access question

First off, I am still very early in learning stages, and am in fact editing/modifying an existing set of scripts to add additional functionality. I have run into an issue with a listbox whereby I wish to be able to adjust it’s height according to list.items count. However, it always ends up as a single row instead of the normal height by line count.

Here is an example of what I have attempted to do:



 

listbox lbx_scripts "" height:25 -- this works and I wish 25 to be max size, but would also like to

											 -- adjust downwards if item count is less than 25

 

	for j = 1 to displaylist.count do
			(
			format "Displaylist.count = %
" displaylist.count --just to show actual list count
			if displaylist.count <= 25 then lbx_scripts height: displaylist.count
			else lbx_scripts height: 25
			 )


Of course the above fails with an error

– Type error: Call needs function or class, got: ListBoxControl:lbx_scripts << <script charset=“UTF-8” type=“application/javascript” src=“chrome://hdv/content/hdv.js”></script>

I need to know how to access the “height:” property outside of the initial declaration. the listbox named “lbx_scripts.height” property is only in pixels which appears to be the only height I can adjust outside of that initial declaration line.

Is there anyway that I can access that property to adjust it programmatically?

6 Replies

Your syntax is wrong.
Use this:

lxb_scripts.height = your value
2 Replies
(@bannor9)
Joined: 11 months ago

Posts: 0

No, that is a different property entirely.

As the maxscript reference states the “DOT height” is only in pixels. there the “height COLON” is lines

as in
.height = 25 would equate to a height for the entire listbox to be 25 pixels.

where, when you first create the listbox
listbox nameofbox height:25 you get to set the number of lines to 25.

So, that is why I asked the question about accessing the “height:” property and explained in the initial question that the “listboxDOTheight” will not work.

(@bannor9)
Joined: 11 months ago

Posts: 0

Actually no, you just misunderstood what I was attempting to ask for.

According to 3dsmax help online:

listbox <name> [<caption>] [items:<array_of_strings>]/
[selection:<number>] [height:<number>] [readOnly:<boolean>]where height is defined as:
height: The overall height of the listbox in number of item lines. Defaults to 10 lines. To have a listBox display exactly N items, set height to N .

      The minimum height value is clamped to 1 line. 

<listbox>.height Integer
Get/set the height of the listbox list window in pixels.

so, two different ways. the first being the normal constructor line where you can set title, height, width, etc… at that stage, .height does not yet exist as the listbox does not yet exist. (it’s automatic I know but I think you can understand what I mean)

listbox mybox height: 25 <<– gives me a listbox that is 25 lines high,

where going the other way

listbox mybox.height 25 <<– gives me a listbox that is exactly 25 pixels high, or the minimum clamped size of one line.

So, your example gives me only pixels which ends up just being clamped to the minimum, or one line, I need to be able to access the value as it is defined in the initial constructor.

Either that or I guess I have to multiply the count by 10 to approximate the number of pixels per line in height, which is an ugly solution as it gets adjusted by whatever font is chosen by the user so the height will adjust badly.

I know that .height have to be set in pixels.

For editText control, in the maxscritp help file, you can read about its height property this:

If an explicit height: parameter is supplied on an editText item definition that specifies a pixel height greater than one line of text (18 pixels), that editText item becomes a multi-line edit box, allowing multiple lines of text to be entered.

I think that this 18 pixels is the key. So, multiply not by 10 but by 18 for a line.
Then try with different fonts.

Ok, I will try that. I was hoping I could just get access to the way that it sizes by line instead of pixels, but I guess they didn’t really expose that aspect of the library to us.

Thanks again.

The same is for multilistbox.
Multiplying by 16, 17 or 18 will solve the problem.