Skip to main content

ContextMenu

Struct ContextMenu 

Source
pub struct ContextMenu {
    pub open: bool,
    pub item_height: usize,
    pub width: usize,
    pub padding: usize,
    pub bg_color: Color,
    pub hover_color: Color,
    pub text_color: Color,
    pub border_color: Color,
    pub border_size: usize,
    pub radius: usize,
    pub font: Option<Font>,
    pub font_size: f32,
    /* private fields */
}

Fields§

§open: bool§item_height: usize§width: usize§padding: usize§bg_color: Color§hover_color: Color§text_color: Color§border_color: Color§border_size: usize§radius: usize§font: Option<Font>§font_size: f32

Implementations§

Source§

impl ContextMenu

Source

pub fn items(self, items: &[&str]) -> Self

Source

pub fn width(self, w: usize) -> Self

Source

pub fn item_height(self, h: usize) -> Self

Source

pub fn font(self, font: Font, size: f32) -> Self

Source

pub fn bg_color(self, color: Color) -> Self

Source

pub fn hover_color(self, color: Color) -> Self

Source

pub fn text_color(self, color: Color) -> Self

Source

pub fn border_color(self, color: Color) -> Self

Source

pub fn border(self, size: usize) -> Self

Source

pub fn radius(self, radius: usize) -> Self

Source

pub fn open(&mut self, x: usize, y: usize)

Opens the context menu at the given position

Source

pub fn close(&mut self)

Closes the context menu

Source

pub fn is_open(&self) -> bool

Source

pub fn clicked_item(&self) -> Option<usize>

Returns the index of the item that was clicked this frame, if any

Source

pub fn draw(&mut self, window: &mut Window)

Trait Implementations§

Source§

impl Default for ContextMenu

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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>,

Source§

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>,

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.