Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ XR Studio

Button (Legacy)

  • Last UpdatedDec 16, 2023
  • 3 minute read

The Button element provides pushbutton functionality. It inherits from RectBase (Legacy).

Note: The legacy 2D nodes hierarchy has been replaced with a new and better performing hierarchy: 2D nodes. You should no longer use these older 2D nodes, except for very specific tasks.

Platform support

This node is supported on XR-Windows platform only.

XR-WIN

XR-P-WIN

XR-P-IOS

XR-P-AND

XR-P-WASM

Full support

No support

No support

No support

No support

Full support

No support

No support

No support

No support

Button behavior

The button aspect depends on how many children it has. The children can be Rect (Legacy) or Text (Legacy).

  • No children: A transparent button.

  • One child: Normal. Clicked and on over states coincide.

  • Two children: The first child is used for normal. The second child is for clicked state. There is no onOver behavior.

  • Three children: The first child is used for normal. The second child for clicked state, and the third child is for onOver.

  • More than three: This configuration is not allowed; only the first three are used.

Toggle and radio buttons

It is possible to implement toggle or radio buttons with a script acting on button selected field. For more information, see Using Legacy 2D nodes.

Code example

This is a code example for the Button node.

<rect name="menu" image="menu_fondo.png" show="false" position="1152 672" center="256 384" size="512 512" scale="0.5 0.5">

<button name="buttonZoomOut" show="true" position="112 256" center="64 64" size="128 128" propagateMouse="false">

<rect image="menu_zoom_out_off.png" order="2" opacity="1" size="128 128" />

<rect image="menu_zoom_out_on.png" order="2" opacity="1" size="128 128" />

</button>

<button name="buttonZoomIn" show="true" position="388 256" center="64 64" size="128 128" propagateMouse="false">

<rect image="menu_zoom_in_off.png" order="2" opacity="1" size="128 128" />

<rect image="menu_zoom_in_on.png" order="2" opacity="1" size="128 128" />

</button>

</rect>

Position

The Button node can be positioned inside a context node, such as Context and Global, or be children of other 2D nodes.

Fields

These are the fields for Button node. Only the node-specific fields are indicated, not fields obtained by inheritance.

Field inheritance: NodeBase > RectBase (Legacy) > Button

Field

Type

Use

Default

Description

buttonDown

sbool

Read only

Not set

Checks if the button is currently clicked.

collisionArea

svec4

Read only

0 0 -1 -1

Defines a restricted collision area inside the button, in screen coordinates. By convention, the default sets the collision area to button size.

collisionArea

sfloat

Optional

0.5

Sets the double click interval time.

doubleClicked

sevent

Read only

Not set

Raised when user performs a double click.

isOver

sbool

Read only

Not set

Checks if the mouse is over the button.

mouseUp

sevent

Read only

Not set

Raises when click action is finished.

mouseDown

sevent

Read only

Not set

Raises when click action is begins.

overX

sfloat

Read only

Not set

If the mouse is over the button, this field contains the x coordinate relative to the top left corner of the button and normalized on the range interval [0..1].

overY

sfloat

Read only

Not set

If the mouse is over the button, this field contains th y coordinate relative to the top left corner of the button and normalized on the range interaval [0..1].

propagateMouse

sbool

Optional

false

If set to true, any mouse events are propagated to the below sensor node.

selected

sbool

Optional

Not set

Sets the selected state of the button. When set to false, sets the first child as normal state. When set to true, sets the second child as normal state. This state can also be Read. It is useful for implementing toggle buttons or radio buttons.

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in