package ui // A simple structure to detect if the cursor has not moved or started moving again. // hoverDetector.update must be called during each Update invocation to track the // frame and the current cursor position. type _hoverDetector struct { last_x, last_y int ticks int } const HOVER_THRESHOLD = 60 var ( hoverDetector _hoverDetector longtapHoverDetector _hoverDetector ) func (h *_hoverDetector) update(x, y int) (ev InputEvent, ch bool) { if x == h.last_x && y == h.last_y { h.ticks = h.ticks + 1 if h.ticks == HOVER_THRESHOLD { return InputEvent{HoverStart, x, y, nil}, true } } else { if h.ticks > HOVER_THRESHOLD { ev = InputEvent{HoverEnd, h.last_x, h.last_y, nil} ch = true } h.ticks = 0 h.last_x, h.last_y = x, y } return }