| Copyright | (C) 2016-2026 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Native.Element.Text.Event
Description
Synopsis
- onLayout :: (LayoutEvent -> action) -> Attribute model action
- onLayoutWith :: (LayoutEvent -> DOMRef -> action) -> Attribute model action
- onLayoutMain :: (LayoutEvent -> action) -> EventHandler model action
- onLayoutMainWith :: (LayoutEvent -> model -> DOMRef -> action) -> EventHandler model action
- onSelectionChange :: (SelectionChangeEvent -> action) -> Attribute model action
- onSelectionChangeWith :: (SelectionChangeEvent -> DOMRef -> action) -> Attribute model action
- onSelectionChangeMain :: (SelectionChangeEvent -> action) -> EventHandler model action
- onSelectionChangeMainWith :: (SelectionChangeEvent -> model -> DOMRef -> action) -> EventHandler model action
- data LayoutEvent = LayoutEvent {}
- data LineInfo = LineInfo {}
- data Size = Size {
- sizeWidth :: Double
- sizeHeight :: Double
- data SelectionChangeEvent = SelectionChangeEvent {}
- data Direction
- layoutDecoder :: Decoder LayoutEvent
- selectionChangeDecoder :: Decoder SelectionChangeEvent
- textEvents :: Events
Events
onLayout :: (LayoutEvent -> action) -> Attribute model action Source #
https://lynxjs.org/api/elements/built-in/text.html#layout
The layout event returns the result information after text layout, including the number of lines of the current text, and the start and end positions of the text in each line relative to the entire text.
data Action = HandleLayout LayoutEvent
view :: context -> props -> Model -> View context Action
view _ _ model = text_ [ onLayout HandleLayout ] [ text "hi" ]
update :: Action -> Effect context props Model Action
update (HandleLayout LayoutEvent {..}) = io_ (consoleLog "layout event received")
onLayoutWith :: (LayoutEvent -> DOMRef -> action) -> Attribute model action Source #
onLayoutMain :: (LayoutEvent -> action) -> EventHandler model action Source #
Like onLayout, but dispatched on the Lynx main thread (MTS).
Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-XStaticPointers.
data Action = HandleLayout LayoutEvent view_ [ event (static (onLayoutMain HandleLayout)) ] [ "some view" ]
onLayoutMainWith :: (LayoutEvent -> model -> DOMRef -> action) -> EventHandler model action Source #
Like onLayoutMain, but the handler also receives read-only access to the
model and the target element's DOMRef (for imperative MTS mutation).
data Action = HandleLayout LayoutEvent Model DOMRef view_ [ event (static (onLayoutMainWith HandleLayout)) ] [ "some view" ]
onSelectionChange :: (SelectionChangeEvent -> action) -> Attribute model action Source #
https://lynxjs.org/api/elements/built-in/text.html#selectionchange
This event is triggered whenever the selected text range changes.
data Action = HandleSelectionChange SelectionChangeEvent
view :: context -> props -> Model -> View context Action
view _ _ model = text_ [ onSelectionChange HandleSelectionChange ] [ text "hi" ]
update :: Action -> Effect context props Model Action
update (HandleSelectionChange SelectionChangeEvent {..}) =
io_ (consoleLog "selection change event received")
onSelectionChangeWith :: (SelectionChangeEvent -> DOMRef -> action) -> Attribute model action Source #
Like onSelectionChange, but the handler also receives the target element's DOMRef.
Use for main-thread (MTS) handlers that imperatively mutate the element.
onSelectionChangeMain :: (SelectionChangeEvent -> action) -> EventHandler model action Source #
Like onSelectionChange, but dispatched on the Lynx main thread (MTS).
Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-XStaticPointers.
data Action = HandleSelectionChange SelectionChangeEvent view_ [ event (static (onSelectionChangeMain HandleSelectionChange)) ] [ "some view" ]
onSelectionChangeMainWith :: (SelectionChangeEvent -> model -> DOMRef -> action) -> EventHandler model action Source #
Like onSelectionChangeMain, but the handler also receives read-only access
to the model and the target element's DOMRef (for imperative MTS mutation).
data Action = HandleSelectionChange SelectionChangeEvent Model DOMRef view_ [ event (static (onSelectionChangeMainWith HandleSelectionChange)) ] [ "some view" ]
Types
data LayoutEvent Source #
Constructors
| LayoutEvent | |
Fields
| |
Instances
| Show LayoutEvent Source # | |
Defined in Miso.Native.Element.Text.Event Methods showsPrec :: Int -> LayoutEvent -> ShowS # show :: LayoutEvent -> String # showList :: [LayoutEvent] -> ShowS # | |
| Eq LayoutEvent Source # | |
Defined in Miso.Native.Element.Text.Event | |
Constructors
| LineInfo | |
Fields | |
Constructors
| Size | |
Fields
| |
data SelectionChangeEvent Source #
Instances
| Show SelectionChangeEvent Source # | |
Defined in Miso.Native.Element.Text.Event Methods showsPrec :: Int -> SelectionChangeEvent -> ShowS # show :: SelectionChangeEvent -> String # showList :: [SelectionChangeEvent] -> ShowS # | |
| Eq SelectionChangeEvent Source # | |
Defined in Miso.Native.Element.Text.Event Methods (==) :: SelectionChangeEvent -> SelectionChangeEvent -> Bool # (/=) :: SelectionChangeEvent -> SelectionChangeEvent -> Bool # | |
Decoders
Event Map
textEvents :: Events Source #