Struct xplm::menu::Menu

source ·
pub struct Menu { /* private fields */ }
Expand description

A menu, which contains zero or more items

Implementations§

source§

impl Menu

source

pub fn new<S: Into<String>>(name: S) -> Result<Self, NulError>

Creates a new menu with the provided name

Returns an error if the name contains a null byte

Examples found in repository?
examples/menus.rs (line 20)
19
20
21
22
23
24
25
26
27
28
29
30
    fn start() -> Result<Self, Self::Error> {
        let plugins_submenu = Menu::new("Menu Test Plugin").unwrap();
        plugins_submenu.add_child(CheckItem::new("Checkable 1", false, CheckHandler1).unwrap());
        plugins_submenu.add_child(ActionItem::new("Action 1", ActionHandler1).unwrap());
        plugins_submenu.add_to_plugins_menu();

        // The menu needs to be part of the plugin struct, or it will immediately get dropped and
        // will not appear
        Ok(MenuPlugin {
            _plugins_submenu: plugins_submenu,
        })
    }
source

pub fn name(&self) -> String

Returns the name of this menu

source

pub fn set_name<S: AsRef<str>>(&self, name: S) -> Result<(), NulError>

Sets the name of this menu

Returns an error if the name contains a null byte

source

pub fn add_child<R, C>(&self, child: R)
where R: Into<Rc<C>>, Rc<C>: Into<Item>,

Adds a child to this menu The child argument may be a Menu, ActionItem, CheckItem, or Separator, or an Rc containing one of these types.

Examples found in repository?
examples/menus.rs (line 21)
19
20
21
22
23
24
25
26
27
28
29
30
    fn start() -> Result<Self, Self::Error> {
        let plugins_submenu = Menu::new("Menu Test Plugin").unwrap();
        plugins_submenu.add_child(CheckItem::new("Checkable 1", false, CheckHandler1).unwrap());
        plugins_submenu.add_child(ActionItem::new("Action 1", ActionHandler1).unwrap());
        plugins_submenu.add_to_plugins_menu();

        // The menu needs to be part of the plugin struct, or it will immediately get dropped and
        // will not appear
        Ok(MenuPlugin {
            _plugins_submenu: plugins_submenu,
        })
    }
source

pub fn add_to_plugins_menu(&self)

Adds this menu as a child of the plugins menu

Examples found in repository?
examples/menus.rs (line 23)
19
20
21
22
23
24
25
26
27
28
29
30
    fn start() -> Result<Self, Self::Error> {
        let plugins_submenu = Menu::new("Menu Test Plugin").unwrap();
        plugins_submenu.add_child(CheckItem::new("Checkable 1", false, CheckHandler1).unwrap());
        plugins_submenu.add_child(ActionItem::new("Action 1", ActionHandler1).unwrap());
        plugins_submenu.add_to_plugins_menu();

        // The menu needs to be part of the plugin struct, or it will immediately get dropped and
        // will not appear
        Ok(MenuPlugin {
            _plugins_submenu: plugins_submenu,
        })
    }
source

pub fn remove_from_plugins_menu(&self)

Removes this menu from the plugins menu

Trait Implementations§

source§

impl Debug for Menu

source§

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

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

impl Drop for Menu

Removes this menu from X-Plane, to prevent the menu handler from running and accessing a dangling pointer

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !Freeze for Menu

§

impl !RefUnwindSafe for Menu

§

impl !Send for Menu

§

impl !Sync for Menu

§

impl Unpin for Menu

§

impl !UnwindSafe for Menu

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<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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.