class TUI::ClickTracker

Overview

Tracks repeated clicks on the same logical target (e.g. a list row index) to detect a double-click, independent of scrolling/rendering — a double-click doesn't require its target to be scrollable.

Defined in:

tui/widget/click_tracker.cr

Constant Summary

DEFAULT_THRESHOLD = 400.milliseconds

Max gap between two clicks on the same target for #register to treat them as a double-click. Overridable per instance via #initialize's threshold argument.

Constructors

Instance Method Summary

Constructor Detail

def self.new(threshold : Time::Span = DEFAULT_THRESHOLD) #

[View source]

Instance Method Detail

def register(target : Int32) : Bool #

Register a click on target. Returns true if this click completes a double-click (same target, within @threshold of the previous click) — and on a true double-click, resets internal state so a third rapid click starts a fresh pair rather than chaining. Returns false otherwise (recording this click as the new "last click").


[View source]