package mosaic

  1. Overview
  2. Docs
Terminal UI framework for OCaml with The Elm Architecture

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.1.0.tbz
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9

doc/mosaic.ui/Mosaic_ui/Event/Mouse/index.html

Module Event.MouseSource

Sourcetype t

The type for mouse events.

Carries cursor coordinates, modifier keys, propagation control, and hit-testing metadata. Variant-specific data (button, source, scroll direction) is accessed by pattern-matching on kind.

Only stop_propagation and prevent_default mutate the event; all other fields are immutable after construction.

Supporting types

Sourcetype button =
  1. | Left
    (*

    Primary (left) button.

    *)
  2. | Middle
    (*

    Middle button.

    *)
  3. | Right
    (*

    Secondary (right) button.

    *)
  4. | Button of int
    (*

    Extended button with one-based index n.

    *)

The type for mouse buttons.

Sourceval equal_button : button -> button -> bool

equal_button a b is true iff a and b are the same button.

Sourceval pp_button : Format.formatter -> button -> unit

pp_button formats a button value.

Sourcetype modifier = Input.Key.modifier = {
  1. ctrl : bool;
    (*

    Control key held.

    *)
  2. alt : bool;
    (*

    Alt / Option key held.

    *)
  3. shift : bool;
    (*

    Shift key held.

    *)
  4. super : bool;
    (*

    Super / Windows / Command key held.

    *)
  5. hyper : bool;
    (*

    Hyper key held.

    *)
  6. meta : bool;
    (*

    Meta key held.

    *)
  7. caps_lock : bool;
    (*

    Caps Lock active.

    *)
  8. num_lock : bool;
    (*

    Num Lock active.

    *)
}

The type for modifier key state. Re-exported from Input.Key.modifier.

Sourceval no_modifier : modifier

no_modifier is the modifier state with every field set to false.

Sourceval equal_modifier : modifier -> modifier -> bool

equal_modifier a b is true iff all modifier fields of a and b are equal.

Sourceval pp_modifier : Format.formatter -> modifier -> unit

pp_modifier formats a modifier value.

Sourcetype scroll_direction = Input.Mouse.scroll_direction =
  1. | Scroll_up
    (*

    Scroll towards the top of the content.

    *)
  2. | Scroll_down
    (*

    Scroll towards the bottom of the content.

    *)
  3. | Scroll_left
    (*

    Scroll towards the left of the content.

    *)
  4. | Scroll_right
    (*

    Scroll towards the right of the content.

    *)

The type for scroll-wheel directions. Re-exported from Input.Mouse.scroll_direction.

Sourceval equal_scroll_direction : scroll_direction -> scroll_direction -> bool

equal_scroll_direction a b is true iff a and b are the same direction.

Sourceval pp_scroll_direction : Format.formatter -> scroll_direction -> unit

pp_scroll_direction formats a scroll_direction value.

Event kinds

Each variant carries exactly the data relevant to that kind of event. Common fields (coordinates, modifiers, target) are accessed via x, y, modifiers, and target.

Sourcetype kind =
  1. | Down of {
    1. button : button;
    }
    (*

    Button pressed.

    *)
  2. | Up of {
    1. button : button;
    2. is_dragging : bool;
    }
    (*

    Button released. is_dragging is true iff a drag was in progress when the button was released.

    *)
  3. | Move
    (*

    Cursor moved with no button pressed.

    *)
  4. | Drag of {
    1. button : button;
    2. is_dragging : bool;
    }
    (*

    Cursor moved with button held. is_dragging is true iff the drag threshold has been exceeded.

    *)
  5. | Drag_end of {
    1. button : button;
    }
    (*

    Drag gesture ended; button was the dragging button.

    *)
  6. | Drop of {
    1. button : button;
    2. source : int option;
    }
    (*

    Drop target reached. source is the node identifier of the drag source, if known.

    *)
  7. | Over of {
    1. source : int option;
    }
    (*

    Cursor moved over a potential drop target. source is the node identifier of the drag source, if known.

    *)
  8. | Out
    (*

    Cursor left a node during a drag.

    *)
  9. | Scroll of {
    1. direction : scroll_direction;
    2. delta : int;
    }
    (*

    Scroll-wheel event. delta is the number of steps in direction.

    *)

The type for mouse event kinds.

Sourceval equal_kind : kind -> kind -> bool

equal_kind a b is true iff a and b are the same constructor and carry equal payloads.

Sourceval pp_kind : Format.formatter -> kind -> unit

pp_kind formats a kind value.

Construction

Sourceval make : x:int -> y:int -> modifiers:modifier -> ?target:int -> kind -> t

make ~x ~y ~modifiers ?target kind is a mouse event at (x, y) with modifier state modifiers, optional hit-test node target, and event kind kind. Propagation and default-prevention flags start as false.

target defaults to None.

Accessors

Sourceval kind : t -> kind

kind t is t's event kind with its variant-specific payload. See kind.

Sourceval x : t -> int

x t is t's horizontal cursor position (0-based column).

Sourceval y : t -> int

y t is t's vertical cursor position (0-based row).

Sourceval modifiers : t -> modifier

modifiers t is t's modifier key state at the time of the event.

Sourceval target : t -> int option

target t is the hit-test target node identifier of t, if any.

Dispatch control

Sourceval stop_propagation : t -> unit

stop_propagation t prevents t from bubbling to ancestor nodes.

Sourceval propagation_stopped : t -> bool

propagation_stopped t is true iff stop_propagation has been called on t.

Sourceval prevent_default : t -> unit

prevent_default t marks renderer-level default behaviour as prevented. This only suppresses renderer-defined defaults (for example, starting a text selection on mouse-down); it does not stop bubbling. Use stop_propagation to prevent bubbling to ancestors.

Sourceval default_prevented : t -> bool

default_prevented t is true iff prevent_default has been called on t.

Sourceval equal : t -> t -> bool

equal a b is true iff a and b have the same kind, coordinates, modifiers, and target. Dispatch control state is ignored.

Sourceval pp : Format.formatter -> t -> unit

pp formats a mouse event for debugging.