SpatialButton constructor
SpatialButton({})
Implementation
SpatialButton({
super.name = 'button',
required super.transform,
required this.label,
required panel,
this.labelColor = const Color(0xFFFFFFFF),
this.idleColor = const Color(0xE0161B22),
this.hoverColor = const Color(0xE01C2333),
this.pressColor = const Color(0xE02E90FA),
void Function(Node)? onPress,
}) : _panel = panel {
pointable = Pointable(
node: this,
onHoverEnter: (_) => _panel.backgroundColor = hoverColor,
onHoverExit: (_) => _panel.backgroundColor = idleColor,
onPress: (node, hit) {
_panel.backgroundColor = pressColor;
onPress?.call(node);
},
onRelease: (_) => _panel.backgroundColor = hoverColor,
);
_panel.backgroundColor = idleColor;
_panel.onRenderContent = _renderLabel;
addChild(_panel);
}