brick-dropdownmenu-0.1.0: A drop-down menu widget for brick.

Copyright(c) Mario Lang 2018
LicenseBSD-style (see the file LICENSE)
Safe HaskellNone




This module provides a simple drop-down menu widget with global key bindings.

A submenu consists of a title, a resource name, and an associated global event. Each menu item consists of the items title, resource name, global event and associated action.

An action is a function s -> EventM n (Next s).



data DropDownMenu s n Source #

Drop-down menus present a menu bar with drop-down submenus.

Drop-down menus support the following events by default:

  • Leftright arrow keys: Switch to previousnext submenu
  • Up arrow key: Close submenu when already at top, otherwise move selection in submenu
  • Down arrow key: Open submenu or move submenu selection downwards
  • Escape: Close submenu
  • Return: Open submenu or invoke selected submenu item
Named (DropDownMenu s n) n Source # 
Instance details

Defined in Brick.Widgets.DropDownMenu


getName :: DropDownMenu s n -> n #

Constructing a drop-down menu

dropDownMenu Source #


:: n

The resource name for this drop-down menu

-> [(String, n, Maybe Event, [(String, n, Maybe Event, s -> EventM n (Next s))])]

Menu description

-> DropDownMenu s n 

Handling events

handleDropDownMenuEvent Source #


:: (Eq n, Ord n) 
=> s

The application state

-> Lens' s (DropDownMenu s n)

A lens for accessing the drop-down menu state

-> (s -> s)

Sets focus to this drop-down menu widget if need be

-> Event

Event received from Vty

-> EventM n (Next s) 

Handle drop-down menu events. This should typically be called from the application event handler if this menu widget has focus.

handleGlobalDropDownMenuEvent Source #


:: (Eq n, Ord n) 
=> s

The application state

-> Lens' s (DropDownMenu s n)

A lens for accessing the drop-down menu state

-> (s -> s)

Set application focus

-> Event

Event received from Vty

-> Maybe (EventM n (Next s)) 

Handle global events. This function will handle global events associated with submenus or menu items. It should typically be called from the main application event handler before any other more specific handlers.

Rendering drop-down menus

renderDropDownMenu Source #


:: (Eq n, Ord n, Show n) 
=> Bool

Does this menu have focus?

-> DropDownMenu s n 
-> Widget n 


Manipulating a drop-down menu

closeDropDownMenu :: DropDownMenu s n -> DropDownMenu s n Source #

Close submenu.