1 begin@ mouse 2 3 type Capture @byval = 4 val x : u32 5 val y : u32 6 val relative_x : u32 7 val relative_y : u32 8 val control : Control 9 10 type Mouse @[mut local] = 11 val link_presses = Stream<(MouseAction, Control, i32)>.new 12 val presses = Stream<(MouseAction, Control)>.new 13 var obs capture : Option<Capture> @[mut internal] = None 14 local obs position : (u32, u32) = (0, 0) 15 let position_to_control : u32 * u32 * (Control -> bool) -> Option<Control> 16 local tokens = List<Token>.new 17 18 def try_captured = case capture of 19 None -> None 20 Some x -> Some x.control 21 22 def try_hovered = 23 let (x, y) = position 24 position_to_control x y { true } 25 26 fun destruct = 27 for i = tokens.size - 1 downto 0 do 28 tokens[i].discard 29