tmenu

package module
v0.0.0-...-73ccc3e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

README

tmenu

tmenu is tview based library that provides a main menu bar widget

To use tmenu follow these steps per cmd/main.go for example

  1. Create the MenuItems that will be your menu bars main items
  2. For each main item add sub MenuItems
  3. Create the MenuBar
  4. Add each main item to the menu bar in the desired order
  5. Add the menu bar to the desired container, such as a flex - don't allow its size to be recomputed
  6. Install the MenuBars AfterDraw() function as part of your AfterDraw routine, or as the main one to the application
  7. Run the application

example

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MenuBar struct {
	*tview.Box
	MenuItems []*MenuItem
	// contains filtered or unexported fields
}

func NewMenuBar

func NewMenuBar() *MenuBar
func (menuBar *MenuBar) AddItem(item *MenuItem) *MenuBar
func (menuBar *MenuBar) AfterDraw() func(tcell.Screen)
func (menuBar *MenuBar) Draw(screen tcell.Screen)
func (menuBar *MenuBar) Focus(delegate func(p tview.Primitive))
func (menuBar *MenuBar) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
func (p *MenuBar) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)
type MenuItem struct {
	*tview.Box
	Title    string
	SubItems []*MenuItem
	// contains filtered or unexported fields
}

func NewMenuItem

func NewMenuItem(title string) *MenuItem
func (menuItem *MenuItem) AddItem(item *MenuItem) *MenuItem
func (menuItem *MenuItem) Draw(screen tcell.Screen)
func (menuItem *MenuItem) SetOnClick(fn func(*MenuItem)) *MenuItem
type SubMenu struct {
	*tview.Box
	Items []*MenuItem
	// contains filtered or unexported fields
}

func NewSubMenu

func NewSubMenu(parent *MenuBar, items []*MenuItem) *SubMenu
func (subMenu *SubMenu) Draw(screen tcell.Screen)
func (subMenu *SubMenu) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL