Skip to reading
GDScript Programming & Godot

Select a list row from GDScript

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
GDSCRIPT PROGRAMMING                                                                            0.86.4.1  /  HOTFIX 1

CHECKED SCRIPTING CALL

A List Box has a registered text property called selectedId. Use the row’s ID when a script needs to highlight a particular choice. The same shared action is callable from all four PCA scripting languages.

Code example
func select_map():
Code example
    var a = {"guiId":"menu", "elementId":"places",
Code example
        "property":"selectedId", "value":"map"}
Code example
    return await ActionResult("ChangeGUIElementProperty", a)

01. Point the call at your own list

Open the GUI in the Runner. For this example its ID is menu, the List Box ID is places, and a row has the ID map. Use a single-selection list with no selectedId binding for this direct write. Substitute your own three IDs if needed.

02. Read the reply

Call the function from an existing script event. Inspect ok and, on failure, error and message. The correct row should highlight. If the target is unavailable, check that the GUI exists, the element ID is correct and you supplied its owning GUI ID.

03. Let a binding own its value

If the list selection is bound to a variable, edit that variable instead. A checked direct write can return bound_property. A width write to a responsive managed or anchored control can return layout_owned; edit the container or the element’s layout constraints.

CURRENT REFERENCE

Validate Action and Property Reference includes 244 action and graph entries, 219 script-callable entries and 709 registered property entries. The property appendix in this edition was rebuilt from the 0.86.4.1 catalog.

PCA 3D ADVENTURE STUDIO                                                                             GDScript   /   378
Page 378 of 378Permalink
Go to page