nano-ui
Safe HaskellNone
LanguageGHC2024

NanoUI.Emit

Description

Widgets for reducer-style applications.

Each function draws a widget from the model and, when the user changes it, emits a message instead of returning the new value. The backend's reducer runner (runSdlAppReduce, runRgfwAppReduce) folds the frame's messages into the model with your update function.

The names match NanoUI, so import this module qualified:

import NanoUI.Emit qualified as Emit

data Msg = Increment | Decrement

view :: Int -> NanoUI ()
view n = row $ do
  Emit.button "-" Decrement
  label (T.pack (show n))
  Emit.button "+" Increment
Synopsis

Documentation

emit :: forall msg (es :: [Effect]). (Typeable msg, Ui :> es) => msg -> Eff es () Source #

button :: forall msg (es :: [Effect]). (Typeable msg, Ui :> es) => Text -> msg -> Eff es () Source #

Emit msg when the button is clicked.

checkbox :: forall msg (es :: [Effect]). (Typeable msg, Ui :> es) => Text -> Bool -> (Bool -> msg) -> Eff es () Source #

slider :: forall msg (es :: [Effect]). (Typeable msg, Ui :> es) => Float -> Float -> Float -> (Float -> msg) -> Eff es () Source #

select :: forall f msg (es :: [Effect]). (Foldable f, Typeable msg, Ui :> es) => f Text -> Int -> (Int -> msg) -> Eff es () Source #

radio :: forall f msg (es :: [Effect]). (Foldable f, Typeable msg, Ui :> es) => f Text -> Int -> (Int -> msg) -> Eff es () Source #

textInput :: forall msg (es :: [Effect]). (Typeable msg, Ui :> es) => Text -> (Text -> msg) -> Eff es () Source #

textArea :: forall msg (es :: [Effect]). (Typeable msg, Ui :> es) => Text -> (Text -> msg) -> Eff es () Source #

Emit the new text after an edit. Caret and scroll changes emit nothing.

tabs :: forall f a msg (es :: [Effect]). (Foldable f, Eq a, Typeable msg, Ui :> es) => a -> f (Tab a (Eff es ())) -> (a -> msg) -> Eff es () Source #

Emit the newly active key when the user switches tabs.