#Using `collection_index` in Form Buttons?

1 messages · Page 1 of 1 (latest)

eternal cobalt
#

I want to edit the properties of a certain button. But how can I use collection_index on form buttons (dynamic_button)?

eternal cobalt
# acoustic ferry Did u find the solution?
{
    "a": {
        "type": "stack_panel",
        "orientation": "horizontal",
        "size": ["100%", "100%"],
        "collection_name": "form_buttons",
        "layer": 0,
        "controls": [{
            "a@server_form.button": {
                "collection_index": 0
            }
        }]
    }
}
acoustic ferry
acoustic ferry
#

here

              "long_form_dynamic_buttons_panel": {
                "type": "stack_panel",
                "size": ["100% - 4px", "100%"],
                "offset": ["5%", "80%"],
                "orientation": "horizontal",
                "anchor_from": "bottom_middle",
                "anchor_to": "bottom_middle",
                "factory": {
                  "name": "buttons",
                  "control_name": "server_form.custom_dynamic_button"
                },
                "collection_name": "form_buttons",
                "bindings": [
                  {
                    "binding_name": "#form_button_length",
                    "binding_name_override": "#collection_length"
                  }
                ]
              }
            }```
#

or

eternal cobalt
#

1st one

acoustic ferry
# eternal cobalt 1st one

alr i tried this but it didnt work

{
              "long_form_dynamic_buttons_panel": {
                "type": "stack_panel",
                "size": ["100% - 4px", "100%"],
                "offset": ["5%", "80%"],
                "orientation": "horizontal",
                "anchor_from": "bottom_middle",
                "anchor_to": "bottom_middle",
                "factory": {
                  "name": "buttons",
                  "control_name": "server_form.custom_dynamic_button"
                },
                "collection_name": "form_buttons",
                "bindings": [
                  {
                    "binding_name": "#form_button_length",
                    "binding_name_override": "#collection_length"
                  }
                ],
                "controls":[
                  {
                    "a@server_form.custom_dynamic_button": {
                      "size": ["40%", 1],
                      "collection_index": 0
                  }
                  }
                ]
              }
            }```
eternal cobalt
#
{
              "long_form_dynamic_buttons_panel": {
                "type": "stack_panel",
                "size": ["100% - 4px", "100%"],
                "orientation": "vertical"
                "collection_name": "form_buttons",
                ],
                "controls":[
                  {
                    "a@server_form.custom_dynamic_button": {
                      "size": ["40%", 1],
                      "collection_index": 0
                  }
                  }
                ]
              }
            }
acoustic ferry
eternal cobalt
acoustic ferry
eternal cobalt
#

uhh no

acoustic ferry
eternal cobalt
#

you can try adding a parent panel to it

#

and add offset to the child

acoustic ferry
# eternal cobalt you can try adding a parent panel to it

like this?

{
              "long_form_dynamic_buttons_panel": {
                "type": "stack_panel",
                "size": ["100% - 4px", "100%"],
                "offset": ["5%", "80%"],
                "orientation": "horizontal",
                "controls":[
                  {
                    "a": {
                      "type": "panel",
                      "offset": ["5%", "0%"],
                      "orientation": "horizontal",
                      "collection_name": "form_buttons",
                      "controls":[
                        {
                          
                          "a@server_form.custom_dynamic_button": {
                            "collection_index": 0
                        }
                        }
                      ]
                    }
                  },
                  {
                    "b": {
                      "type": "panel",
                      "offset": ["10%", "0%"],
                      "orientation": "horizontal",
                      "collection_name": "form_buttons",
                      "controls":[
                        {
                          
                          "b@server_form.custom_dynamic_button": {
                            "collection_index": 1
                        }
                        }
                      ]
                    }
                  }
                ]
              }
            }```
eternal cobalt
#

no

#

remove the oreintation and collectionname

acoustic ferry
#

truee

acoustic ferry
eternal cobalt
#

uhh, try playing with the values and properties

acoustic ferry
#
[UI][error]-UI Control: long_form | UI Control: page1 | UI Control: second | UI Control: long_form_dynamic_buttons_panel | ----------------------------------------------------
Unknown properties found in def[a] from namespace[common]
- Unknown property [collection_name]
----------------------------------------------------


[UI][error]-UI Control: long_form | UI Control: page1 | UI Control: second | UI Control: long_form_dynamic_buttons_panel | UI Control: b | ----------------------------------------------------
Unknown properties found in def[b] from namespace[server_form]
- Unknown property [collection_index]
----------------------------------------------------


[UI][error]-UI Control: long_form | UI Control: page1 | UI Control: second | UI Control: long_form_dynamic_buttons_panel | ----------------------------------------------------
Unknown properties found in def[b] from namespace[common]
- Unknown property [collection_name]
----------------------------------------------------```
acoustic ferry
eternal cobalt
#

hmmm unparent the childs ig

acoustic ferry
tame barn
#

don't cross posting.

acoustic ferry
#

How do I unparent

eternal cobalt
#

remove the panela

#

*panels

acoustic ferry
# eternal cobalt remove the panela

remove the "types": "panel"
Like this or

{
              "long_form_dynamic_buttons_panel": {
                "type": "stack_panel",
                "size": ["100% - 4px", "100%"],
                "offset": ["5%", "80%"],
                "orientation": "horizontal",
                "controls":[
                  {
                    "a": {
                      "type": "panel",
                      "offset": ["5%", "0%"],
                      "orientation": "horizontal",
                      "collection_name": "form_buttons",
                      "controls":[
                        {
                          
                          "a@server_form.custom_dynamic_button": {
                            "collection_index": 0
                        }
                        }
                      ]
                    }
                  },
                  {
                    "b": {
                      "type": "panel",
                      "offset": ["10%", "0%"],
                      "orientation": "horizontal",
                      "collection_name": "form_buttons",
                      "controls":[
                        {
                          
                          "b@server_form.custom_dynamic_button": {
                            "collection_index": 1
                        }
                        }
                      ]
                    }
                  }
                ]
              }
            }```
acoustic ferry
acoustic ferry
#

ok found the solution
and for all the people who use the search bar, this allows you to change specific/certain form buttons using collection_index

{
              "buttons": {
                "type": "panel",
                "controls": [
                  {
                    "<": {
                      "type": "stack_panel",
                      "size": ["100% - 4px", "100%"],
                      "offset": ["5%", "80%"],
                      "orientation": "horizontal",
                      "collection_name": "form_buttons",
                      "controls": [
                        {
                          "<@server_form.custom_dynamic_button": {
                            "collection_index": 0
                          }
                        }
                      ]
                    }
                  },
                  {
                    ">": {
                      "type": "stack_panel",
                      "size": ["100% - 4px", "100%"],
                      "offset": ["85%", "80%"],
                      "orientation": "horizontal",
                      "collection_name": "form_buttons",
                      "controls": [
                        {
                          ">@server_form.custom_dynamic_button": {
                            "collection_index": 1
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            }```
eternal cobalt
acoustic ferry
#

this worked tho

#

wtf

eternal cobalt
acoustic ferry
eternal cobalt
#

great if it works 👍🏻

acoustic ferry
#

what is the better way

eternal cobalt
#

afaik, you can only add offset if the element is inside a panel inside of a stack

#

like:

"stack"
    "panel1"
        "button1": offset
    "panel2"
        "button2": offset
acoustic ferry
# eternal cobalt like: ```json "stack" "panel1" "button1": offset "panel2" ...

like this

 {
              "long_form_dynamic_buttons_panel": {
                "type": "stack_panel",
                "size": ["100% - 4px", "100%"],
                "orientation": "horizontal",
                "collection_name": "form_buttons",
                "controls": [
                  {
                    "a": {
                      "type": "panel",
                      "controls": [
                        {
                          "a@server_form.custom_dynamic_button": {
                            "offset": ["5%", "80%"],
                            "collection_index": 0
                          }
                        }
                      ]
                    }
                  },
                  {
                    "b": {
                      "type": "panel",
                      "controls": [
                        {
                          "b@server_form.custom_dynamic_button": {
                            "offset": ["85%", "80%"],
                            "collection_index": 1
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            }```
eternal cobalt
#

yeah

#

you may also define size on panels

acoustic ferry
# eternal cobalt you may also define size on panels

im getting these errors

[UI][error]-UI Control: long_form | UI Control: page1 | UI Control: second | UI Control: long_form_dynamic_buttons_panel | UI Control: a | ----------------------------------------------------
Unknown properties found in def[a] from namespace[server_form]
- Unknown property [collection_index]
----------------------------------------------------


[UI][error]-UI Control: long_form | UI Control: page1 | UI Control: second | UI Control: long_form_dynamic_buttons_panel | ----------------------------------------------------
Unknown properties found in def[a] from namespace[common]
- Unknown property [collection_name]
- Unknown property [orientation]
----------------------------------------------------


[UI][error]-UI Control: long_form | UI Control: page1 | UI Control: second | UI Control: long_form_dynamic_buttons_panel | UI Control: b | ----------------------------------------------------
Unknown properties found in def[b] from namespace[server_form]
- Unknown property [collection_index]
----------------------------------------------------


[UI][error]-UI Control: long_form | UI Control: page1 | UI Control: second | UI Control: long_form_dynamic_buttons_panel | ----------------------------------------------------
Unknown properties found in def[b] from namespace[common]
- Unknown property [collection_name]
- Unknown property [orientation]
----------------------------------------------------```
eternal cobalt
#

try changing the panels to stack panels and add the collection name + orientation

acoustic ferry
acoustic ferry
#

another question how do i how do i make a server form fit the entire screen

#

and all screens also gui scale modifications

eternal cobalt
#

100%, 100%

acoustic ferry
#

Tried :(

#

But maybe in the wrong elements

acoustic ferry
eternal cobalt
#

main element

#

which contains everything

acoustic ferry
# eternal cobalt main element

well the issue is that i have a conditional rendering which shows screen if it's name is E and if i use the size 100% it doesnt work for some reason

#
"long_form": {
    "controls": [
      {
        "default@common_dialogs.main_panel_no_buttons": {
          "$title_panel": "common_dialogs.standard_title_label",
          "$title_size": ["100% - 14px", 10],
          "size": [225, 200],
          "$text_name": "#title_text",
          "$title_text_binding_type": "none",
          "$child_control": "server_form.long_form_panel",
          "layer": 2,
          "bindings": [
            {
              "binding_type": "global",
              "binding_name": "#title_text",
              "binding_name_override": "#text"
            },
            {
              "binding_type": "view",
              "source_property_name": "(not (#text = 'E'))",
              "target_property_name": "#visible"
            }
          ]
        }
      },
      {
        "page1@server_form.test": {
          "bindings": [
            {
              "binding_type": "global",
              "binding_name": "#title_text",
              "binding_name_override": "#text"
            },
            {
              "binding_type": "view",
              "source_property_name": "(#text = 'E')",
              "target_property_name": "#visible"
            }
          ]
        }
      }
    ]
  },```
eternal cobalt
#

try changing the size of main_screen_content

acoustic ferry
eternal cobalt
#

yeah you can definitely try

eternal cobalt
#

change the size of main_screen_content to 100% and long form/page1 to 100%

acoustic ferry
#

sure

eternal cobalt
#

hmm

acoustic ferry
acoustic ferry
eternal cobalt
#

idk kinda busy sorry

acoustic ferry
random jolt
#

I think it should be this one, to make it change size

acoustic ferry
#

If the form page name is not E then it will show the default one

random jolt
acoustic ferry
#

My objective is to make the GUI work with all gui scale modifications

random jolt
acoustic ferry
granite marsh
# acoustic ferry what is the better way

Depending on the use case, a lot of times its easier to just wrap all the stack child elements in a panel with 0 size, then you can manually offset their controls.

acoustic ferry
#

Maybe I did something wrong

granite marsh
eternal cobalt
acoustic ferry
#

Hm

#

I will retest rn

granite marsh
acoustic ferry
#

@granite marsh

granite marsh
acoustic ferry
#

true

acoustic ferry
eternal cobalt
#

Just make the panel size to 0 and try..

acoustic ferry
#

sure

eternal cobalt
acoustic ferry
acoustic ferry
# eternal cobalt If that doesn't work, you can stick with this ^

i think this is enough

"test": {
    "type": "panel",
    "layer": 3,
    "anchor_from": "center",
    "anchor_to": "center",
    "controls": [
      {
        "[email protected]_image_border_white": {
          "controls": [
            {
              "background": {
                "type": "image",
                "visible": false,
                "texture": "textures/Black",
                "size": ["100%", "100%"],
                "alpha": 0.5,
                "keep_ratio": false
              }
            },
            {
              "back_button@close_button": {
                "anchor_from": "top_right",
                "anchor_to": "top_right",
                "offset": [-5, 5]
              }
            },
            {
              "buttons": {
                "type": "panel",
                "controls": [
                  {
                    "<@server_form.button":{"$button":0,"offset": ["5%", "80%"]}
                  },
                  {
                    "<@server_form.button":{"$button":1,"offset": ["85%", "80%"]}
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },
  "button": {
    "type": "stack_panel",
    "size": ["100% - 4px", "100%"],
    "offset": ["5%", "80%"],
    "orientation": "horizontal",
    "$button":0,
    "collection_name": "form_buttons",
    "controls": [
      {
        "button@server_form.custom_dynamic_button": {
          "collection_index": "$button"
        }
      }
    ]
  },```
granite marsh
amber locust
#

@acoustic ferry dm