Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides a simple dialog widget. You get to pick the dialog title, if any, as well as its body and buttons.
- data Dialog a
- dialogTitle :: Dialog a -> Maybe String
- dialogName :: Dialog a -> Name
- dialogButtons :: Dialog a -> [(String, a)]
- dialogSelectedIndex :: Dialog a -> Maybe Int
- dialogWidth :: Dialog a -> Int
- dialog :: Name -> Maybe String -> Maybe (Int, [(String, a)]) -> Int -> Dialog a
- renderDialog :: Dialog a -> Widget -> Widget
- dialogSelection :: Dialog a -> Maybe a
- dialogAttr :: AttrName
- buttonAttr :: AttrName
- buttonSelectedAttr :: AttrName
- dialogNameL :: forall a. Lens' (Dialog a) Name
- dialogButtonsL :: forall a a. Lens (Dialog a) (Dialog a) [(String, a)] [(String, a)]
- dialogSelectedIndexL :: forall a. Lens' (Dialog a) (Maybe Int)
- dialogWidthL :: forall a. Lens' (Dialog a) Int
- dialogTitleL :: forall a. Lens' (Dialog a) (Maybe String)
Documentation
Dialogs present a window with a title (optional), a body, and
buttons (optional). They provide a HandleEvent
instance that knows
about Tab and Shift-Tab for changing which button is active. Dialog
buttons are labeled with strings and map to values of type a
, which
you choose.
Dialogs handle the following events by default:
- Tab: selecte the next button
- Shift-tab: select the previous button
HandleEvent (Dialog a) Source |
dialogTitle :: Dialog a -> Maybe String Source
The dialog title
dialogName :: Dialog a -> Name Source
The dialog name
dialogButtons :: Dialog a -> [(String, a)] Source
The dialog button labels and values
dialogSelectedIndex :: Dialog a -> Maybe Int Source
The currently selected dialog button index (if any)
dialogWidth :: Dialog a -> Int Source
The maximum width of the dialog
Construction and rendering
:: Name | The dialog name, provided so that you can use this as a basis for viewport names in the dialog if desired |
-> Maybe String | The dialog title |
-> Maybe (Int, [(String, a)]) | The currently-selected button index (starting at zero) and the button labels and values to use |
-> Int | The maximum width of the dialog |
-> Dialog a |
Create a dialog.
renderDialog :: Dialog a -> Widget -> Widget Source
Render a dialog with the specified body widget.
Getting a dialog's current value
dialogSelection :: Dialog a -> Maybe a Source
Obtain the value associated with the dialog's currently-selected
button, if any. This function is probably what you want when someone
presses Enter
in a dialog.
Attributes
The default attribute of the dialog
The default attribute for all dialog buttons
buttonSelectedAttr :: AttrName Source
The attribute for the selected dialog button (extends dialogAttr
)
Lenses
dialogNameL :: forall a. Lens' (Dialog a) Name Source
dialogWidthL :: forall a. Lens' (Dialog a) Int Source