monomer-1.6.0.1: A GUI library for writing native Haskell applications.
Copyright(c) 2018 Francisco Vallarino
LicenseBSD-3-Clause (see the LICENSE file)
Maintainerfjvallarino@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Monomer.Main.UserUtil

Description

Helper functions for Monomer users, to simplify common operations such as focus change and clipboard requests.

Synopsis

Documentation

setFocusOnKey :: WidgetEnv s e -> WidgetKey -> EventResponse s e sp ep Source #

Deprecated: Use SetFocusOnKey instead (wenv argument should be removed).

Generates a response to set focus on the given key, provided as WidgetKey. If the key does not exist, focus will remain on the currently focused widget.

setClipboardData :: ClipboardData -> EventResponse s e sp ep Source #

Generates a response that sets the clipboard to the given data

setCursorIcon :: WidgetNode s e -> CursorIcon -> EventResponse s e sp ep Source #

Generates a response that sets the cursor to the given icon

resetCursorIcon :: WidgetNode s e -> EventResponse s e sp ep Source #

Generates a response that resets the cursor icon

exitApplication :: EventResponse s e sp ep Source #

Generates a response that exits the application

cancelExitApplication :: EventResponse s e sp ep Source #

Generates a response that cancels a request to exit the application

widgetIf :: Bool -> WidgetNode s e -> WidgetNode s e Source #

Returns the provided widget when True, otherwise returns an invisible placeholder.

Useful for conditionally adding a widget to a list.

vstack [
  label "Label 1",
  widgetIf isValid (label "Label 2")
]

widgetMaybe :: Maybe a -> (a -> WidgetNode s e) -> WidgetNode s e Source #

Returns the result of applying the function when the provided value is Just, otherwise returns an invisible placeholder.

Useful for conditionally adding a widget to a list.

styleIf :: Bool -> StyleState -> StyleState Source #

Returns the provided style when True, otherwise returns the empty style.

Useful for conditionally setting a style.

label "Test"
  `styleBasic` [
    textFont "Medium",
    styleIf invalidUser (textColor red)
  ]

styleMaybe :: Maybe a -> (a -> StyleState) -> StyleState Source #

Returns the result of applying the function when the provided value is Just, otherwise returns the empty style.

Useful for conditionally setting a style.

configIf :: Monoid a => Bool -> a -> a Source #

Returns the provided configuration value when True, otherwise returns the default (mempty) configuration value.

Useful for conditionally setting a configuration value.

label_ "Test" [textFont "Medium", configIf showAll multiline]

configMaybe :: Monoid a => Maybe b -> (b -> a) -> a Source #

Returns the result of applying the function when the provided value is Just, otherwise returns the default (mempty) configuration value.

Useful for conditionally setting a configuration value.

responseIf :: Bool -> EventResponse s e sp ep -> EventResponse s e sp ep Source #

Returns the provided EventResponse when True, otherwise returns a no-op.

Useful for conditionally returning a response.

...
_ -> [Model newModel, responseIf isValid (SetFocusOnKey "widgetKey")]

responseMaybe :: Maybe (EventResponse s e sp ep) -> EventResponse s e sp ep Source #

Returns the provided EventResponse when Just, otherwise returns a no-op.

Useful for conditionally returning a response.

...
_ -> [Model newModel, responseMaybe maybeResp]