MultipleClickSensor

Helper struct to detect double clicks, triple clicks, or overall repeated clicks.

To make use of the sensor, you need to call its two methods — hold and activate — whenever the relevant event occurs. hold should be called for every instance, whereas activate should only be called if the event is active. For example, to implement double clicks via mouse using input actions, you'd need to implement two input handlers:

mixin enableInputActions;
TimeIO timeIO;
PreferenceIO preferenceIO;
DoubleClickSensor sensor;

override void resizeImpl(Vector2) {
    require(timeIO);
    require(preferenceIO);
}

@(FluidInputAction.press, WhileHeld)
override bool hold(HoverPointer pointer) {
    sensor.hold(timeIO, preferenceIO, pointer);
}

@(FluidInputAction.press)
override bool press(HoverPointer) {
    sensor.activate();
}

Members

Functions

activate
void activate()

Call this function every time the desired click event is active.

clear
void clear()

Clear the counter, resetting click count to 0.

hold
void hold(TimeIO timeIO, PreferenceIO preferenceIO, Vector2 pointerPosition)

Call this function every time the desired click event is emitted.

hold
void hold(TimeIO timeIO, PreferenceIO preferenceIO, HoverPointer pointer)

Call this function every time the desired click event is emitted.

hold
void hold(MonoTime currentTime, Duration doubleClickInterval, float maximumDistance, Vector2 pointerPosition)

Call this function every time the desired click event is emitted.

Variables

clicks
int clicks;

Number of registered clicks.

Meta