Skip to main content

ai_agent/interact/events/
click_event.rs

1// Source: ~/claudecode/openclaudecode/src/ink/events/click-event.ts
2
3use super::event::Event;
4
5/// Mouse click event. Fired on left-button release without drag, only when
6/// mouse tracking is enabled (i.e. inside <AlternateScreen>).
7///
8/// Bubbles from the deepest hit node up through parentNode. Call
9/// stop_immediate_propagation() to prevent ancestors' on_click from firing.
10#[derive(Debug, Clone)]
11pub struct ClickEvent {
12    /// 0-indexed screen column of the click
13    pub col: u32,
14    /// 0-indexed screen row of the click
15    pub row: u32,
16    /// Click column relative to the current handler's Box (col - box.x).
17    /// Recomputed by dispatch_click before each handler fires, so an on_click
18    /// on a container sees coords relative to that container, not to any
19    /// child the click landed on.
20    pub local_col: u32,
21    /// Click row relative to the current handler's Box (row - box.y).
22    pub local_row: u32,
23    /// True if the clicked cell has no visible content (unwritten in the
24    /// screen buffer — both packed words are 0). Handlers can check this to
25    /// ignore clicks on blank space to the right of text, so accidental
26    /// clicks on empty terminal space don't toggle state.
27    pub cell_is_blank: bool,
28    /// Base event for propagation control
29    base: Event,
30}
31
32impl ClickEvent {
33    pub fn new(col: u32, row: u32, cell_is_blank: bool) -> Self {
34        Self {
35            col,
36            row,
37            local_col: 0,
38            local_row: 0,
39            cell_is_blank,
40            base: Event::new(),
41        }
42    }
43
44    pub fn did_stop_immediate_propagation(&self) -> bool {
45        self.base.did_stop_immediate_propagation()
46    }
47
48    pub fn stop_immediate_propagation(&self) {
49        self.base.stop_immediate_propagation();
50    }
51}