2023-03-08 09:36 AM - edited 2023-03-08 09:44 AM
Hi All,
How might you go about creating a scrollable UI list that has 3 columns based on two array parameters? A [i][2] text array, and a [i] boolean array.
I currently just have it adding lines as it loops based on the top input, but that can hit the limitations of the bounding box. I can extend it to two columns, which would meet the majority of use cases, but I figured it would be better to make it more flexible.
Ling.
ps. Though, now I get array dimension errors since I merged one of the parameters into a second column of the array...
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
Solved! Go to Solution.
2023-03-21 04:44 AM - edited 2023-03-21 04:49 AM
I decided to use ui_listitem and got it working within a loop, though it does not preview properly with x/y being inverted... The down side is that my text input is on a second line below the checkbox.
ui_listfield 1, 10, 60, 432, 200
ui_listitem 1, 1, "", 0, "", "Storey Levels"
FOR i = 2 to (sg_noStoreyAbove + 1)
IF sg_base_toggle then
IF i = 2 then
name = "Reference Offset"
ELSE
name = sg_name_prefix + STR ("%2.0", i-2)
endIF
ELSE
name = sg_name_prefix + STR ("%2.0", i-1)
endIF
ui_listitem{2} i, 1, sg_styToSty[i-1], 1, "", name
next i
ui_listitem i+2, 1, "", 0, "", "Basement Levels"
FOR j = 2 to (sg_noBasement + 1)
name = sg_nameBase_prefix + STR ("%2.0", j-1)
ui_listitem{2} i+2+j*j, 1, sg_basementHTs[j-1], 1, "", name
next j
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2023-03-08 11:35 AM - edited 2023-03-08 11:41 AM
Hello @Lingwisyer ,
I have one way of doing it but it isn't really a scrollbar, just the UI redisplaying lines depending on a specific position.
Using your 2 array parameters :
ui_array_bool as a 1 dimensional array
ui_array_text as a 2 dimensional array
Requires 3 additional parameters :
ui_pos as an integer param
ui_checkbox_plus as a bool parameter
ui_checkbox_minus as a bool parameter
In Main script :
LINES_MAX = 5 ! Max number of displayed lines
POS = ui_pos
LINES = vardim1(ui_array_bool)
if LINES > LINES_MAX then
NUM = LINES - LINES_MAX
else
NUM = LINES_MAX
endif
MINI_UI = -int(NUM)
! Increments, decrements position and update checkboxes
if ui_checkbox_plus then
POS = POS + 1
parameters ui_checkbox_plus = 0
ENDIF
if ui_checkbox_minus then
POS = POS - 1
parameters ui_checkbox_minus = 0
ENDIF
! Prevents the pos to go out of the min and max possible position
if POS < MINI_UI then
POS = MINI_UI
else
if POS > 0 then
POS = 0
endif
endif
ui_pos = POS
if not(LINES > LINES_MAX) then
ui_pos = 0
endif
In Parameters script :
parameters ui_pos = ui_pos
if ui_pos = 0 then lock "ui_checkbox_plus"
if ui_pos = MINI_UI then lock "ui_checkbox_minus"
In UI script :
x0 = 5
y0 = 5
dy = 20
x = x0
y = y0
if LINES > LINES_MAX then
ROW_MIN = (LINES - LINES_MAX) + ui_pos
else
ROW_MIN = 0
endif
ROW_MAX = LINES + ui_pos
for row = ROW_MAX-ROW_MIN to 1 step -1
ACTUAL_ROW = ROW_MAX + 1 - row
ui_outfield "Level "+str(ACTUAL_ROW,1,0), x, y : x = x + 50
ui_infield{3} ui_array_bool[ACTUAL_ROW], x, y-4, 20, 20 : x = x + 20
ui_infield{3} ui_array_text[ACTUAL_ROW][2], x, y-4, 20, 20
x = x0
y = y + dy
next row
ui_infield{3} ui_checkbox_minus, x+100, y0-4, 20, 20
ui_infield{3} ui_checkbox_plus, x+100, y-dy-4, 20, 20
2023-03-09 08:52 AM
I made UI that can change display width and height (little buttons on top and left) plus its generate new page if content can't fit current page - look at Material button. Originally object had opportunity to change each letter material in 3D to whatever user choose. Here's only UI script.
Tbh object is messy, because it was made long ago, when i only started learning. That's why some part for UI is in master script and many others issues. But it works, so you can see if you need this kind of approach.
2023-03-21 04:44 AM - edited 2023-03-21 04:49 AM
I decided to use ui_listitem and got it working within a loop, though it does not preview properly with x/y being inverted... The down side is that my text input is on a second line below the checkbox.
ui_listfield 1, 10, 60, 432, 200
ui_listitem 1, 1, "", 0, "", "Storey Levels"
FOR i = 2 to (sg_noStoreyAbove + 1)
IF sg_base_toggle then
IF i = 2 then
name = "Reference Offset"
ELSE
name = sg_name_prefix + STR ("%2.0", i-2)
endIF
ELSE
name = sg_name_prefix + STR ("%2.0", i-1)
endIF
ui_listitem{2} i, 1, sg_styToSty[i-1], 1, "", name
next i
ui_listitem i+2, 1, "", 0, "", "Basement Levels"
FOR j = 2 to (sg_noBasement + 1)
name = sg_nameBase_prefix + STR ("%2.0", j-1)
ui_listitem{2} i+2+j*j, 1, sg_basementHTs[j-1], 1, "", name
next j
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |