Bootstrap Chameleon Logo

Variable Placeholder

VariablePlaceholder

Variable Placeholders

In the JSON file, variables are replaced with the values of the variables at runtime. The following are variable placeholders in TPython:

"%"

The most commonly used placeholder, it can be replaced with various values, depending on the control it is in. For example, in SSpinBox, it will be replaced with the value of the SpinBox, which can be a float or int according to the type of the SSpinBox; while in SColorPicker, it will be replaced with the value of the color. In other text controls, it will be replaced with the corresponding string.

SSpinBox.OnValueChanged SSlider.OnValueChanged SColorPicker.OnColorCommitted SCheckBox.OnCheckStateChanged SExpandableArea.OnAreaExpansionChanged SBreadcrumbTrail.OnCrumbClick SSearchBox.OnTextChanged SEditableText.OnTextChanged SEditableTextBox.OnTextChanged SMultiLineEditableText.OnTextChanged SMultiLineEditableTextBox.OnTextChanged SSearchBox.OnTextCommitted SEditableText.OnTextCommitted SEditableTextBox.OnTextCommitted SMultiLineEditableText.OnTextCommitted SMultiLineEditableTextBox.OnTextCommitted

"%JsonPath"

In Chameleon's interface JSON file, we have a fixed syntax in "InitPyCmd". For example, the syntax in MinimalExample:

"InitPyCmd": "import Example; chameleon_example = Example.MinimalExample.MinimalExample(%JsonPath)"

At runtime, "%JsonPath" will be replaced with the current JSON file's path, so the MinimalExample class can obtain the current JSON file's path. This path is the unique identifier for differentiating various ChameleonData instances.

"%actors"

SDropTarget.OnDrop is used to get the Actor dragged by the user, and its function can be replaced by "%**kwargs". For more details, refer to: Drag and Drop Area

"%assets"

SDropTarget.OnDrop, like "%actors", is used to get the assets dragged by the user, and its function can be replaced by "%**kwargs". For more details, refer to: Drag and Drop Area

"%folders"

SDropTarget.OnDrop is used to get the folders dragged by the user, and its function can be replaced by "%**kwargs". For more details, refer to: Drag and Drop Area

"%assets_folders"

SDropTarget.OnDrop is used to get the asset folders dragged by the user, and its function can be replaced by "%**kwargs". For more details, refer to: Drag and Drop Area

"%**kwargs"

"%Index" is used in SListView and STreeView to get the index of the Item clicked by the user. For more details, refer to: Drag and Drop Area

"%Index"

"%Index" is used in SListView and STreeView to get the index of the Item clicked by the user. For more details, refer to: List View

SListView.OnSelectedChanged SListView.OnMouseButtonDoubleClick SListView.OnSelectedChanged SListView.OnMouseButtonDoubleClick STreeView.OnSelectedChanged STreeView.OnMouseButtonDoubleClick

"%Item"

Like "%Index", it is used to get the Item clicked by the user. For more details, refer to: List View

SListView.OnSelectionChanged SListView.OnMouseButtonDoubleClick STreeView.OnSelectionChanged

"%uv"

"%uv" is used to get the UV coordinates clicked by the user in SImage. For more details, refer to: Use Images and Image Brush

SImage.OnMouseEnter SImage.OnMouseMove

"%mouse_flags"

Similarly, "%mouse_flags" is used to get the state of the mouse buttons. For more details, refer to: Use Images and Image Brush

SImage.OnMouseEnter SImage.OnMouseMove SImage.OnMouseLeave

"%WidgetPath"

%WidgetPath" is used to get the path of the SButton clicked by the user. For more details, refer to: Buttons

SButton.OnClick

"%SelectionType"

"%SelectionType" is used to get the reason for the change in the value of SComboBox. Possible values are:

  • "OnKeyPress"
  • "OnNavigation"
  • "OnMouseClick"
  • "Direct"

SComboBox.OnSelectionChanged

"%map_change_type"

In Chameleon Tool, the "OnMapChangedCmd" is used to execute Python commands when the Map is switched.

Uses:

  • Detect level switching and update the interface synchronously
  • Chameleon tools clean up references during level switching to avoid memory leaks or crashes triggered by memory leak detection

For more details, refer to OnCloseCallback

  • "LoadMap"
  • "SaveMap"
  • "NewMap"
  • "TearDownWorld"

"%world"

In Chameleon Tool's "OnMapChangedCmd", like the "%map_change_type" mentioned above, it is used to get information about the new world (level).

Extra
In MenuItem, there are also "%asset_paths", "%context", "%floatArgs", "%intArgs", "%paths", "%strArgs", and "%tool_path" placeholders. Their functions can now be completely replaced by other tools and are no longer recommended for use.

Keywords

In addition to variable placeholders, there are some common keywords or property names in the "Content", "Slots", and Slate components. The following are some of the more common keywords.

  • "Text"
  • "HAlign"
  • "VAlign"
  • "FillColumn"
  • "Padding"
  • "ColorAndOpacity"
  • "WidthOverride"
  • "HeightOverride"
  • "MinDesiredWidth"
  • "MaxDesiredWidth"
  • "MinDesiredHeight"
  • "MaxDesiredHeight"
  • "AutoHeight"
  • "AutoWidth"
  • "ContentPadding"
  • "Orientation"
  • "Thickness"
  • "Font"
  • "Justification"
  • "ShadowOffset"
  • "ShadowColorAndOpacity",
  • "TextStyle"
  • "HintText"
  • "IsReadOnly"
  • "SelectAllTextWhenFocused",
  • "AutoWrapText"
  • "CheckBoxStyle"
  • "FillWidth"
  • "FillHeight"
  • "ItemHeight"
  • "Margin"
  • "IsChecked"
  • "ToolTipText"
  • "OnTextChanged"
  • "OnTextCommitted"
  • "DelayChangeNotificationWhi
  • "Visibility"
  • "Size"
  • "ButtonColorAndOpacity",
  • "ForegroundColor"
  • "BackgroundColor"
  • "MinDesiredSlotWidth"
  • "MinDesiredSlotHeight"
  • "SlotPadding"
  • "ImagePath"
  • "ImagePathInPlugin"
  • "ButtonContent"
  • "OnGetMenuContent"
  • "HasDownArrow"
  • "HighlightText"
  • "WrapTextAt"
  • "WrappingPolicy"
  • "LineHeightPercentage"
  • "Marshaller"
  • "RichText"
  • "DecoratorStyleSet"
  • "ButtonStyle"
  • "Style"
  • "Position"
  • "EnableAnimatedScrolling"
  • "OnTick"
  • "BorderBackgroundColor"
  • "BorderImage"
  • "BodyBorderImage"
  • "HeaderPadding"
  • "AllowAnimatedTransition"
  • "InitiallyCollapsed"
  • "MinWidth"
  • "HeaderContent"
  • "BodyContent"
  • "MinAspectRatio"
  • "MaxAspectRatio"

NOTE
Component-specific keywords are not fully included. Please refer to the component's API documentation for more information.

There are currently 43 supported SWidget components:

SMultiLineEditableText SRichTextBlock SColorBlock SColorWheel SImage SProgressBar SSpacer SSlider STextBlock SBox SCanvas SGridPanel SUniformGridPanel SOverlay SUniformWrapPanel SSplitter SHorizontalBox SVerticalBox SComboButton SComboBox SEditableText SHeader SBreadcrumbTrail SCheckBox SColorPicker SDropTarget SScrollBox SSpinBox SThrobber SExpandableArea SBorder SHeaderRow SSeparator SButton SHyperlink SMultiLineEditableTextBox" SEditableTextBox SSearchBox SListView SListView STreeView SDetailsView SWebBrowser