Actionable

Register on Lenra

Element of type Actionable

actionable

This component makes its child actionable based on the defined properties.

When stacking two or more actionables of the same size and using the same attribute, only the lowest one in the tree will be called.

Examples

Making a text clickable

{
    "type": "actionable",
    "onPressed": {
        "action": "textPress",
        "props": {
            ...
        }
    },
    "child": {
        "type": "text", 
        "value": "This is an actionable text."
    }
}

Handling multiple events.

{
    "type": "actionable",
    "onPressed": {
        "action": "pressedOnceAction",
    },
    "onDoublePressed": {
        "action": "doublePressedAction",
    },
    "onLongPressed": {
        "action": "longPressedAction",
    },
    "onHovered": {
        "action": "hoveredAction",
    },
    "child": {
        "type": "text", 
        "value": "This is an actionable text."
    }
}

Stacking actionables with same attribute.

{
    "type": "actionable",
    "onPressed": {
        // Will not be called because there is an actionable below that defines the onPressed attribute
        // Note that if this actionable was sized to be bigger than the actionable below, it would be possible to trigger this onPressed
        "action": "willNotBeCalled",
    },
    "onDoublePressed": {
        // Will be called because there is no actionable below that defines this attribute
        "action": "willBeCalled",
    },
    "child": {
        "type": "actionable",
        "onPressed": {
            "action": "willBeCalled",
        },
        "child": {
            "type": "text", 
            "value": "This is an actionable text."
        }
    }
}

Properties

AttributeDescriptionType
typeThe identifier of the componentstring ("actionable")
childcomponent
onDoublePressedThe listener to be called when the actionable is double pressed.Basic Listener
onHoveredThe listener to be called when the actionable is hovered and when the mouse exits the hoverable area.Basic Listener
onLongPressedThe listener to be called when the actionable is long pressed.Basic Listener
onPressedThe listener to be called when the actionable is pressed.Basic Listener
onPressedCancelThe listener to be called when the actionable is pressed inside and released outside of the actionable, causing it to cancel the press action.Basic Listener