类型 MenubarState

API 文档由 Go 源码生成,内容为英文。

type MenubarState ui.ID

MenubarState is caller-owned top-level popup state. Its zero value is closed; a nonzero value is the stable ID of the active trigger.

构造函数

MenubarHover#

func MenubarHover(state MenubarState, trigger ui.ID, now time.Time, intent *HoverIntent, delay time.Duration) (MenubarState, time.Duration)

MenubarHover advances the menubar's hover switch: while a menu is open, resting on another trigger opens that trigger's menu after delay. With no open menu, or with the pointer on the open trigger, it does nothing. It returns the state and the wait before asking again.

MenubarKeyDown#

func MenubarKeyDown(current ui.ID, triggers []MenubarTrigger, open MenubarState, direction Direction, key ui.Key) (MenubarState, ui.ID, bool)

MenubarKeyDown moves the menubar's keyboard focus and, while a menu is open, switches the open menu with it. Left and Right move between triggers with wrapping (reversed in RTL), Home and End go to the ends, Down/Enter/Space open the focused trigger, and Escape closes the open menu and returns to its trigger. Items inside the open menu are the caller's to focus after an open.

方法

ActiveID#

func (state MenubarState) ActiveID() ui.ID

ActiveID returns the open trigger ID, or zero when the menubar is closed.

Close#

func (MenubarState) Close() MenubarState

Close returns the state with no active popup.

Dismiss#

func (MenubarState) Dismiss() MenubarState

Dismiss closes the active popup after selection or a dismiss action.

Escape#

func (MenubarState) Escape() MenubarState

Escape closes the active popup after the runtime routes an Escape key press.

IsOpen#

func (state MenubarState) IsOpen() bool

IsOpen reports whether any top-level menu is open.

IsOpenFor#

func (state MenubarState) IsOpenFor(triggerID ui.ID) bool

IsOpenFor reports whether triggerID owns the open popup.

Open#

func (state MenubarState) Open(triggerID ui.ID) MenubarState

Open returns the state with triggerID active. Zero IDs are ignored.

OutsidePress#

func (MenubarState) OutsidePress() MenubarState

OutsidePress closes the active popup after the runtime identifies an outside press.

Toggle#

func (state MenubarState) Toggle(triggerID ui.ID) MenubarState

Toggle closes the active trigger or opens a different nonzero trigger.