Skip to content

Manual Content: Flex Panel docs could do with improvements for editing layerElements at runtime (elementId usage) #14188

@tinkerer-red

Description

@tinkerer-red

What is the problem this request aims to solve?

The current Flex Panel documentation makes it easy to assume that layerElements are “static” once created, because editing the struct returned by flexpanel_node_get_struct() does not update the live element.

As a result, users may believe the only way to change a Sprite/Text element at runtime is to rebuild nodes/panels (clone -> destroy -> recreate), especially for common tasks like tinting a sprite or updating text. This is both error-prone and discourages usage of Sprite/Text layerElements in UI layers.

Currently the only things I know of which suggest that elementId are able to be used in layer functions are these two small references.

Image Image Image

(thank you endy and shdwcat in the kitchen discord for these suggestions)

How do you suggest we solve this problem?

Documentation improvements:

  1. Add a dedicated section under Flex Panels/UI Layers runtime docs titled something like:
  • “Editing Sprite/Text/Object layerElements at runtime (using elementId)”
  1. Provide a minimal example showing:
  • Fetch a flex node struct
  • Read layerElements[n].elementId
  • Call layer_sprite_blend() / layer_text_text() using that handle
    Example:
var _root = layer_get_flexpanel_node("UI_Layer");
var _panel = flexpanel_node_get_child(_root, "FlexPanel");
var _struct = flexpanel_node_get_struct(_panel);

// Assume layerElements[0] is a Sprite element
var _sprite_element_id = _struct.layerElements[0].elementId;
layer_sprite_blend(_sprite_element_id, c_red);

// Assume layerElements[1] is a Text element
var _text_element_id = _struct.layerElements[1].elementId;
layer_text_text(_text_element_id, "HP: 50");
  1. Explicitly warn users that:
  • Editing the returned struct does not mutate the live elements.
  • The correct approach is to use elementId + layer element APIs.

Metadata

Metadata

Labels

documentationImprovements or additions to documentation are also required by this issue

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions