package miaou-core

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file key_event.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(******************************************************************************)
(*                                                                            *)
(* SPDX-License-Identifier: MIT                                               *)
(* Copyright (c) 2026 Nomadic Labs <contact@nomadic-labs.com>                 *)
(*                                                                            *)
(******************************************************************************)

(** Unified key event result type for all widgets and pages.

    This eliminates the inconsistency where:
    - Focus_ring returned [`Handled | `Bubble]
    - Button returned bool
    - Checkbox returned just t

    All key handlers now return [t * result] where result indicates
    whether the key was consumed. *)

type result =
  | Handled  (** Key was consumed by this handler *)
  | Bubble  (** Key was not handled, should propagate to parent *)

let to_bool = function Handled -> true | Bubble -> false

let of_bool b = if b then Handled else Bubble

let handled = Handled

let bubble = Bubble

let to_poly = function Handled -> `Handled | Bubble -> `Bubble

let of_poly = function `Handled -> Handled | `Bubble -> Bubble