miso
Copyright(C) 2016-2026 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.Native.Element.Text.Event

Description

 
Synopsis

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 #

Like onLayout, but the handler also receives the target element's DOMRef. Use for main-thread (MTS) handlers that imperatively mutate the element.

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 LineInfo Source #

Instances

Instances details
Show LineInfo Source # 
Instance details

Defined in Miso.Native.Element.Text.Event

Eq LineInfo Source # 
Instance details

Defined in Miso.Native.Element.Text.Event

FromJSON LineInfo Source # 
Instance details

Defined in Miso.Native.Element.Text.Event

data Size Source #

Constructors

Size 

Instances

Instances details
Show Size Source # 
Instance details

Defined in Miso.Native.Element.Text.Event

Methods

showsPrec :: Int -> Size -> ShowS #

show :: Size -> String #

showList :: [Size] -> ShowS #

Eq Size Source # 
Instance details

Defined in Miso.Native.Element.Text.Event

Methods

(==) :: Size -> Size -> Bool #

(/=) :: Size -> Size -> Bool #

data Direction Source #

Constructors

Forward 
Backward 

Instances

Instances details
Show Direction Source # 
Instance details

Defined in Miso.Native.Element.Text.Event

Eq Direction Source # 
Instance details

Defined in Miso.Native.Element.Text.Event

FromJSON Direction Source # 
Instance details

Defined in Miso.Native.Element.Text.Event

Decoders

Event Map