MenuItem

Struct MenuItem 

Source
pub struct MenuItem<Kind, UserData = (), Api = Default, const REMOVE_ON_DROP: bool = true>(/* private fields */)
where
    Kind: Kind,
    UserData: Into<Box<UserData>>,
    Api: Api;

Implementations§

Source§

impl<UD, K: Kind, Api: Api, const REM: bool> MenuItem<K, UD, Api, REM>

Source

pub fn title(&self) -> Cow<'_, str>

Gets the display title of the menu item.

Returns sys::ffi::playdate_sys::getMenuItemTitle

Source

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

Sets the display title of the menu item.

Returns sys::ffi::playdate_sys::setMenuItemTitle

Source

pub fn get_userdata(&self) -> Option<&mut UD>

Source

pub fn set_userdata(&self, userdata: UD) -> Option<UD>

Set userdata, replace and return old userdata.

Source

pub fn value(&self) -> c_int

Gets the integer value of the menu item.

See also MenuItem::set_value.

Equivalent to sys::ffi::playdate_sys::getMenuItemValue

Source

pub fn set_value(&self, value: c_int)

Sets the integer value of the menu item.

For checkmark menu items (CheckMenuItem), 1 means checked, 0 unchecked.

For option menu items (OptionsMenuItem), the value indicates the array index of the currently selected option.

See also CheckMenuItem::is_checked, OptionsMenuItem::selected_option.

Equivalent to sys::ffi::playdate_sys::setMenuItemValue

Source§

impl<UD: Sized, Api: Api, const REM: bool> MenuItem<Check, UD, Api, REM>

Source

pub fn new<S: AsRef<str>>( title: S, checked: bool, callback: Option<fn(userdata: &mut UD)>, userdata: UD, ) -> Result<Self, ApiError>
where Api: Default,

Source

pub fn new_with<S: AsRef<str>>( api: Api, title: S, checked: bool, callback: Option<fn(userdata: &mut UD)>, userdata: UD, ) -> Result<Self, ApiError>

Source§

impl<UD: Sized, Api: Api, const REM: bool> MenuItem<Simple, UD, Api, REM>

Source

pub fn new<S: AsRef<str>>( title: S, callback: Option<fn(userdata: &mut UD)>, userdata: UD, ) -> Result<Self, ApiError>
where Api: Default,

Source

pub fn new_with<S: AsRef<str>>( api: Api, title: S, callback: Option<fn(userdata: &mut UD)>, userdata: UD, ) -> Result<Self, ApiError>

Source§

impl<UD: Sized, Api: Api, const REM: bool> MenuItem<Options, UD, Api, REM>

Source

pub fn new<S: AsRef<str>, O: AsRef<[S]>>( title: S, options: O, callback: Option<fn(userdata: &mut UD)>, userdata: UD, ) -> Result<Self, ApiError>
where Api: Default,

Source

pub fn new_with<S: AsRef<str>, O: AsRef<[S]>>( api: Api, title: S, options: O, callback: Option<fn(userdata: &mut UD)>, userdata: UD, ) -> Result<Self, ApiError>

Source§

impl<UD, Api: Api, const REM: bool> MenuItem<Check, UD, Api, REM>

Source§

impl<UD, Api: Api, const REM: bool> MenuItem<Options, UD, Api, REM>

Source

pub fn selected_option(&self) -> i32

The array index of the currently selected option.

Equivalent to sys::ffi::playdate_sys::getMenuItemValue

Source§

impl<UD, K: Kind, Api: Api, const REM: bool> MenuItem<K, UD, Api, REM>

Source

pub fn remove(self) -> Option<UD>

Trait Implementations§

Source§

impl<Kind, UserData, Api, const REMOVE_ON_DROP: bool> Debug for MenuItem<Kind, UserData, Api, REMOVE_ON_DROP>
where Kind: Kind + Debug, UserData: Into<Box<UserData>> + Debug, Api: Api + Debug,

Source§

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

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

impl<UD, K: Kind, Api: Api, const REM: bool> Drop for MenuItem<K, UD, Api, REM>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<Kind, UserData, Api, const REMOVE_ON_DROP: bool> Freeze for MenuItem<Kind, UserData, Api, REMOVE_ON_DROP>
where Api: Freeze,

§

impl<Kind, UserData, Api, const REMOVE_ON_DROP: bool> RefUnwindSafe for MenuItem<Kind, UserData, Api, REMOVE_ON_DROP>
where Api: RefUnwindSafe, Kind: RefUnwindSafe, UserData: RefUnwindSafe,

§

impl<Kind, UserData = (), Api = Default, const REMOVE_ON_DROP: bool = true> !Send for MenuItem<Kind, UserData, Api, REMOVE_ON_DROP>

§

impl<Kind, UserData = (), Api = Default, const REMOVE_ON_DROP: bool = true> !Sync for MenuItem<Kind, UserData, Api, REMOVE_ON_DROP>

§

impl<Kind, UserData, Api, const REMOVE_ON_DROP: bool> Unpin for MenuItem<Kind, UserData, Api, REMOVE_ON_DROP>
where Api: Unpin, Kind: Unpin, UserData: Unpin,

§

impl<Kind, UserData, Api, const REMOVE_ON_DROP: bool> UnwindSafe for MenuItem<Kind, UserData, Api, REMOVE_ON_DROP>
where Api: UnwindSafe, Kind: UnwindSafe, UserData: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.