Copyright | (c) 2018 Francisco Vallarino |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | fjvallarino@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Helper functions for Monomer users, to simplify common operations such as focus change and clipboard requests.
Synopsis
- setFocusOnKey :: WidgetEnv s e -> WidgetKey -> EventResponse s e sp ep
- setClipboardData :: ClipboardData -> EventResponse s e sp ep
- setCursorIcon :: WidgetNode s e -> CursorIcon -> EventResponse s e sp ep
- resetCursorIcon :: WidgetNode s e -> EventResponse s e sp ep
- exitApplication :: EventResponse s e sp ep
- cancelExitApplication :: EventResponse s e sp ep
- widgetIf :: Bool -> WidgetNode s e -> WidgetNode s e
- widgetMaybe :: Maybe a -> (a -> WidgetNode s e) -> WidgetNode s e
- styleIf :: Bool -> StyleState -> StyleState
- styleMaybe :: Maybe a -> (a -> StyleState) -> StyleState
- configIf :: Monoid a => Bool -> a -> a
- configMaybe :: Monoid a => Maybe b -> (b -> a) -> a
- responseIf :: Bool -> EventResponse s e sp ep -> EventResponse s e sp ep
- responseMaybe :: Maybe (EventResponse s e sp ep) -> EventResponse s e sp ep
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]