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 |
Dropdown widget, allowing selection of a single item from a collapsable list. Both header and list content are customizable, and so is their styling.
In case only Text
content is needed, Monomer.Widgets.Singles.TextDropdown is
easier to use.
makeSelected username = hstack [ label "Selected: ", spacer, label username ] makeRow username = label username customDropdown = dropdown userLens usernames makeSelected makeRow
Note: the content of the dropdown list will only be updated when the provided
items change, based on their Eq
instance. In case data external to the items
is used for building the row nodes, mergeRequired
may be needed to avoid stale
content.
Synopsis
- data DropdownCfg s e a
- type DropdownItem a = SelectListItem a
- dropdown :: (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) => ALens' s a -> t a -> (a -> WidgetNode s e) -> (a -> WidgetNode s e) -> WidgetNode s e
- dropdown_ :: (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) => ALens' s a -> t a -> (a -> WidgetNode s e) -> (a -> WidgetNode s e) -> [DropdownCfg s e a] -> WidgetNode s e
- dropdownV :: (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) => a -> (Int -> a -> e) -> t a -> (a -> WidgetNode s e) -> (a -> WidgetNode s e) -> WidgetNode s e
- dropdownV_ :: (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) => a -> (Int -> a -> e) -> t a -> (a -> WidgetNode s e) -> (a -> WidgetNode s e) -> [DropdownCfg s e a] -> WidgetNode s e
- dropdownD_ :: forall s e t a. (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) => WidgetData s a -> t a -> (a -> WidgetNode s e) -> (a -> WidgetNode s e) -> [DropdownCfg s e a] -> WidgetNode s e
Configuration
data DropdownCfg s e a Source #
Configuration options for dropdown:
onFocus
: event to raise when focus is received.onFocusReq
:WidgetRequest
to generate when focus is received.onBlur
: event to raise when focus is lost.onBlurReq
:WidgetRequest
to generate when focus is lost.onChange
: event to raise when selected item changes.onChangeReq
:WidgetRequest
to generate when selected item changes.onChangeIdx
: event to raise when selected item changes. Includes index,onChangeIdxReq
:WidgetRequest
to generate when selected item changes. Includes index.maxHeight
: maximum height of the list when dropdown is expanded.itemBasicStyle
:Style
of an item in the list when not selected.itemSelectedStyle
:Style
of the selected item in the list.mergeRequired
: whether merging the items in the list is required. Useful when the content displayed depends on external data, since changes to data outside the provided list cannot be detected. In general it is recommended to only depend on data contained in the list itself, making sure theEq
instance of the item type is correct.
Instances
type DropdownItem a = SelectListItem a Source #
Constraints for an item handled by dropdown.
Constructors
:: (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) | |
=> ALens' s a | The lens into the model. |
-> t a | The list of selectable items. |
-> (a -> WidgetNode s e) | Function to create the header (always visible). |
-> (a -> WidgetNode s e) | Function to create the list (collapsable). |
-> WidgetNode s e | The created dropdown. |
Creates a dropdown using the given lens.
:: (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) | |
=> ALens' s a | The lens into the model. |
-> t a | The list of selectable items. |
-> (a -> WidgetNode s e) | Function to create the header (always visible). |
-> (a -> WidgetNode s e) | Function to create the list (collapsable). |
-> [DropdownCfg s e a] | The config options. |
-> WidgetNode s e | The created dropdown. |
Creates a dropdown using the given lens. Accepts config.
:: (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) | |
=> a | The current value. |
-> (Int -> a -> e) | The event to raise on change. |
-> t a | The list of selectable items. |
-> (a -> WidgetNode s e) | Function to create the header (always visible). |
-> (a -> WidgetNode s e) | Function to create the list (collapsable). |
-> WidgetNode s e | The created dropdown. |
Creates a dropdown using the given value and onChange
event handler.
:: (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) | |
=> a | The current value. |
-> (Int -> a -> e) | The event to raise on change. |
-> t a | The list of selectable items. |
-> (a -> WidgetNode s e) | Function to create the header (always visible). |
-> (a -> WidgetNode s e) | Function to create the list (collapsable). |
-> [DropdownCfg s e a] | The config options. |
-> WidgetNode s e | The created dropdown. |
Creates a dropdown using the given value and onChange
event handler.
| Accepts config.
:: forall s e t a. (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) | |
=> WidgetData s a | The |
-> t a | The list of selectable items. |
-> (a -> WidgetNode s e) | Function to create the header (always visible). |
-> (a -> WidgetNode s e) | Function to create the list (collapsable). |
-> [DropdownCfg s e a] | The config options. |
-> WidgetNode s e | The created dropdown. |
Creates a dropdown providing a WidgetData instance and config.