Click
Introduction
A Click event is raised when an InteractiveGue is first pressed, then released. This can occur with a mouse cursor or a touch screen press/release.
The Click event is used by most Gum Forms controls to raise their own Click event, and to update visual state.
Click Definition
A click occurs when the following happens:
The user presses on the InteractiveGue (touch or mouse button not down last frame, is down this frame)
The user releases on the same InteractiveGue (touch or mouse button was down last frame, is not down this frame)
For simplicity the following code can be used to test click events:
var button = new Button();
button.AddToRoot();
button.Anchor(Gum.Wireframe.Anchor.Center);
// Button's Click event internally uses an InteractiveGue's Click, so
// we can test when clicks are raised by subscribing to a Button's Click
button.Click += (_, _) =>
button.Text = DateTime.Now.ToString();
Clicking (pressing, then releasing) on the button raises the Click event which updates the button's text. Notice that the click is raised on release, and that the cursor can move away from the initial press location so long as it is still within the bounds of the same pressed instance.

A click is even raised if the press happens on the button, the cursor is moved off of the button, then moved back on the button before being released.

If the moue button is pressed when not hovering over the instance, then a click is not raised even if the user released the mouse over the instance.

Last updated
Was this helpful?