Skip to main content

MenuController

Struct MenuController 

Source
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

Source

pub fn new(app: &mut App) -> Ref<MenuController>

Creates a MenuController, attached to no anchor.

Source

pub fn is_open(controller: AnyMenuController, app: &App) -> bool

Source

pub fn open( controller: AnyMenuController, app: &mut App, position: Option<Offset>, )

Source

pub fn close(controller: AnyMenuController, app: &mut App)

Source

pub fn close_children(controller: AnyMenuController, app: &mut App)

Source

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.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl MenuControllerLeaf for MenuController

Source§

fn menu_controller_data(self: Handle<Self>, app: &App) -> &MenuControllerData

Dart’s MenuController fields, held under the field menu_controller (menu_controller_accessors!).
Source§

fn menu_controller_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut MenuControllerData

Source§

fn is_open(self: Handle<Self>, app: &App) -> bool

Whether or not the menu associated with this MenuController is open.
Source§

fn open(self: Handle<Self>, app: &mut App, position: Option<Offset>)

Opens the menu that this MenuController is associated with. Read more
Source§

fn close(self: Handle<Self>, app: &mut App)

Close the menu that this MenuController is associated with. Read more
Source§

fn close_children(self: Handle<Self>, app: &mut App)

Close the children of the menu associated with this MenuController, without closing the menu itself.
Source§

fn as_menu_controller(self: Handle<Self>) -> AnyMenuController

This controller as the erased AnyMenuController: what to pass where a Dart API takes a MenuController.

Auto Trait Implementations§

§

impl Forget for MenuController

§

impl Freeze for MenuController
where NonZero<u32>: Freeze, &'static RawMenuAnchorBaseVTable: Freeze,

§

impl Move for MenuController

§

impl RefUnwindSafe for MenuController

§

impl Send for MenuController
where NonZero<u32>: Send, &'static RawMenuAnchorBaseVTable: Send,

§

impl Sync for MenuController
where NonZero<u32>: Sync,

§

impl Unpin for MenuController
where NonZero<u32>: Unpin, &'static RawMenuAnchorBaseVTable: Unpin,

§

impl UnsafeUnpin for MenuController
where NonZeroU32Inner: UnsafeUnpin, &'static RawMenuAnchorBaseVTable: UnsafeUnpin,

§

impl UnwindSafe for MenuController
where NonZero<u32>: UnwindSafe, &'static RawMenuAnchorBaseVTable: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,