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.Widgets.Containers.Dropdown

Description

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

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 the Eq instance of the item type is correct.

Instances

Instances details
Monoid (DropdownCfg s e a) Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

mempty :: DropdownCfg s e a #

mappend :: DropdownCfg s e a -> DropdownCfg s e a -> DropdownCfg s e a #

mconcat :: [DropdownCfg s e a] -> DropdownCfg s e a #

Semigroup (DropdownCfg s e a) Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

(<>) :: DropdownCfg s e a -> DropdownCfg s e a -> DropdownCfg s e a #

sconcat :: NonEmpty (DropdownCfg s e a) -> DropdownCfg s e a #

stimes :: Integral b => b -> DropdownCfg s e a -> DropdownCfg s e a #

Default (DropdownCfg s e a) Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

def :: DropdownCfg s e a #

CmbMaxHeight (DropdownCfg s e a) Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

maxHeight :: Double -> DropdownCfg s e a Source #

CmbItemBasicStyle (DropdownCfg s e a) Style Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

CmbItemSelectedStyle (DropdownCfg s e a) Style Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

WidgetEvent e => CmbOnBlur (DropdownCfg s e a) e Path Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

onBlur :: (Path -> e) -> DropdownCfg s e a Source #

WidgetEvent e => CmbOnChange (DropdownCfg s e a) a e Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

onChange :: (a -> e) -> DropdownCfg s e a Source #

WidgetEvent e => CmbOnChangeIdx (DropdownCfg s e a) e a Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

onChangeIdx :: (Int -> a -> e) -> DropdownCfg s e a Source #

WidgetEvent e => CmbOnFocus (DropdownCfg s e a) e Path Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

onFocus :: (Path -> e) -> DropdownCfg s e a Source #

CmbOnBlurReq (DropdownCfg s e a) s e Path Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

onBlurReq :: (Path -> WidgetRequest s e) -> DropdownCfg s e a Source #

CmbOnChangeIdxReq (DropdownCfg s e a) s e a Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

onChangeIdxReq :: (Int -> a -> WidgetRequest s e) -> DropdownCfg s e a Source #

CmbOnChangeReq (DropdownCfg s e a) s e a Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

onChangeReq :: (a -> WidgetRequest s e) -> DropdownCfg s e a Source #

CmbOnFocusReq (DropdownCfg s e a) s e Path Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

onFocusReq :: (Path -> WidgetRequest s e) -> DropdownCfg s e a Source #

CmbMergeRequired (DropdownCfg s e a) (WidgetEnv s e) (Seq a) Source # 
Instance details

Defined in Monomer.Widgets.Containers.Dropdown

Methods

mergeRequired :: (WidgetEnv s e -> Seq a -> Seq a -> Bool) -> DropdownCfg s e a Source #

type DropdownItem a = SelectListItem a Source #

Constraints for an item handled by dropdown.

Constructors

dropdown Source #

Arguments

:: (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.

dropdown_ Source #

Arguments

:: (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.

dropdownV Source #

Arguments

:: (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.

dropdownV_ Source #

Arguments

:: (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.

dropdownD_ Source #

Arguments

:: forall s e t a. (WidgetModel s, WidgetEvent e, Traversable t, DropdownItem a) 
=> WidgetData s a

The WidgetData to retrieve the value from.

-> 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.