pub struct MenuController { /* private fields */ }Expand description
A controller used to manage a menu created by a RawMenuAnchor or a
RawMenuAnchorGroup, or by a widget built on them, such as Material’s MenuAnchor,
MenuBar and SubmenuButton.
A MenuController is used to control and interrogate a menu after it has been created,
with methods such as open and
close, and state accessors like
is_open.
MenuController::maybe_of can be used to retrieve a controller from the BuildContext
of a widget that is a descendant of a RawMenuAnchor or a RawMenuAnchorGroup. Doing
so will not establish a dependency relationship.
A controller is an arena object: whoever keeps the Ref new answers holds
it, and so does every anchor widget it is given to. A type that overrides Dart’s members is a
second MenuControllerLeaf.
The associated functions on this type are the shared bodies of Dart’s MenuController; a
leaf calls one where Dart writes super.….
Implementations§
Source§impl MenuController
impl MenuController
Sourcepub fn new(app: &mut App) -> Ref<MenuController>
pub fn new(app: &mut App) -> Ref<MenuController>
Creates a MenuController, attached to no anchor.
Sourcepub fn is_open(controller: AnyMenuController, app: &App) -> bool
pub fn is_open(controller: AnyMenuController, app: &App) -> bool
Sourcepub fn close(controller: AnyMenuController, app: &mut App)
pub fn close(controller: AnyMenuController, app: &mut App)
Sourcepub fn close_children(controller: AnyMenuController, app: &mut App)
pub fn close_children(controller: AnyMenuController, app: &mut App)
Sourcepub fn maybe_of(app: &App, context: BuildContext) -> Option<AnyMenuController>
pub fn maybe_of(app: &App, context: BuildContext) -> Option<AnyMenuController>
Returns the MenuController of the ancestor RawMenuAnchor nearest to the given
context, if one exists. Otherwise, returns None.
This method will not establish a dependency relationship, so the calling widget will not
rebuild when the menu opens and closes, nor when the MenuController changes.
Sourcepub fn maybe_is_open_of(app: &mut App, context: BuildContext) -> Option<bool>
pub fn maybe_is_open_of(app: &mut App, context: BuildContext) -> Option<bool>
Returns the value of MenuControllerLeaf::is_open of the ancestor RawMenuAnchor
or RawMenuAnchorGroup nearest to the given context, if one exists. Otherwise,
returns None.
This method will establish a dependency relationship, so the calling widget will rebuild when the menu opens and closes.
Trait Implementations§
Source§impl Debug for MenuController
impl Debug for MenuController
Source§impl MenuControllerLeaf for MenuController
impl MenuControllerLeaf for MenuController
menu_controller_data.Source§fn is_open(self: Handle<Self>, app: &App) -> bool
fn is_open(self: Handle<Self>, app: &App) -> bool
MenuController is open.Source§fn open(self: Handle<Self>, app: &mut App, position: Option<Offset>)
fn open(self: Handle<Self>, app: &mut App, position: Option<Offset>)
MenuController is associated with. Read moreSource§fn close(self: Handle<Self>, app: &mut App)
fn close(self: Handle<Self>, app: &mut App)
MenuController is associated with. Read moreSource§fn close_children(self: Handle<Self>, app: &mut App)
fn close_children(self: Handle<Self>, app: &mut App)
MenuController, without closing
the menu itself.AnyMenuController: what to pass where a Dart API takes
a MenuController.