Trait MenuExt
pub unsafe trait MenuExt: WidgetExt {
Show 37 methods
// Required methods
fn find_item(&self, name: &str) -> Option<MenuItem> ⓘ;
fn set_item(&mut self, item: &MenuItem) -> bool;
fn find_index(&self, label: &str) -> i32;
fn text_font(&self) -> Font;
fn set_text_font(&mut self, c: Font);
fn text_size(&self) -> i32;
fn set_text_size(&mut self, c: i32);
fn text_color(&self) -> Color;
fn set_text_color(&mut self, c: Color);
fn add<F>(
&mut self,
name: &str,
shortcut: Shortcut,
flag: MenuFlag,
cb: F,
) -> i32
where F: FnMut(&mut Self) + 'static,
Self: Sized;
fn insert<F>(
&mut self,
idx: i32,
name: &str,
shortcut: Shortcut,
flag: MenuFlag,
cb: F,
) -> i32
where F: FnMut(&mut Self) + 'static,
Self: Sized;
fn add_emit<T>(
&mut self,
label: &str,
shortcut: Shortcut,
flag: MenuFlag,
sender: Sender<T>,
msg: T,
) -> i32
where T: 'static + Clone + Send + Sync,
Self: Sized;
fn insert_emit<T>(
&mut self,
idx: i32,
label: &str,
shortcut: Shortcut,
flag: MenuFlag,
sender: Sender<T>,
msg: T,
) -> i32
where T: 'static + Clone + Send + Sync,
Self: Sized;
fn remove(&mut self, idx: i32);
fn add_choice(&mut self, text: &str) -> i32;
fn choice(&self) -> Option<String> ⓘ;
fn value(&self) -> i32;
fn set_value(&mut self, v: i32) -> bool;
fn clear(&mut self);
fn clear_submenu(&mut self, idx: i32) -> Result<(), FltkError> ⓘ;
unsafe fn unsafe_clear(&mut self);
fn size(&self) -> i32;
fn text(&self, idx: i32) -> Option<String> ⓘ;
fn at(&self, idx: i32) -> Option<MenuItem> ⓘ;
fn mode(&self, idx: i32) -> MenuFlag;
fn set_mode(&mut self, idx: i32, flag: MenuFlag);
fn end(&mut self);
fn set_down_frame(&mut self, f: FrameType);
fn down_frame(&self) -> FrameType;
fn global(&mut self);
fn menu(&self) -> Option<MenuItem> ⓘ;
unsafe fn set_menu(&mut self, item: MenuItem);
fn item_pathname(
&self,
item: Option<&MenuItem>,
) -> Result<String, FltkError> ⓘ;
fn set_menu_frame(&mut self, f: FrameType);
fn menu_frame(&self) -> FrameType;
fn mvalue(&self) -> Option<MenuItem> ⓘ;
fn prev_mvalue(&self) -> Option<MenuItem> ⓘ;
}
dep_fltk
only.Expand description
Defines the methods implemented by all menu widgets These are found in the menu module: MenuBar, SysMenuBar, Choice, MenuButton …etc. Menus function in 2 main ways which are discussed in the wiki
§Safety
fltk-rs traits depend on some FLTK internal code
§Warning
fltk-rs traits are non-exhaustive,
to avoid future breakage if you try to implement them manually,
use the Deref and DerefMut pattern or the widget_extends!
macro
Required Methods§
fn find_index(&self, label: &str) -> i32
fn find_index(&self, label: &str) -> i32
Find an item’s index by its label
fn set_text_font(&mut self, c: Font)
fn set_text_font(&mut self, c: Font)
Sets the text font
fn set_text_size(&mut self, c: i32)
fn set_text_size(&mut self, c: i32)
Sets the text size
fn text_color(&self) -> Color
fn text_color(&self) -> Color
Return the text color
fn set_text_color(&mut self, c: Color)
fn set_text_color(&mut self, c: Color)
Sets the text color
fn add<F>(
&mut self,
name: &str,
shortcut: Shortcut,
flag: MenuFlag,
cb: F,
) -> i32
fn add<F>( &mut self, name: &str, shortcut: Shortcut, flag: MenuFlag, cb: F, ) -> i32
Add a menu item along with its callback. The characters “&”, “/”, “\”, and “_” (underscore) are treated as special characters in the label string. The “&” character specifies that the following character is an accelerator and will be underlined. The “\” character is used to escape the next character in the string. Labels starting with the “_” (underscore) character cause a divider to be placed after that menu item. Takes the menu item as a closure argument
fn insert<F>(
&mut self,
idx: i32,
name: &str,
shortcut: Shortcut,
flag: MenuFlag,
cb: F,
) -> i32
fn insert<F>( &mut self, idx: i32, name: &str, shortcut: Shortcut, flag: MenuFlag, cb: F, ) -> i32
Inserts a menu item at an index along with its callback. The characters “&”, “/”, “\”, and “_” (underscore) are treated as special characters in the label string. The “&” character specifies that the following character is an accelerator and will be underlined. The “\” character is used to escape the next character in the string. Labels starting with the “_” (underscore) character cause a divider to be placed after that menu item. Takes the menu item as a closure argument
fn add_emit<T>(
&mut self,
label: &str,
shortcut: Shortcut,
flag: MenuFlag,
sender: Sender<T>,
msg: T,
) -> i32
fn add_emit<T>( &mut self, label: &str, shortcut: Shortcut, flag: MenuFlag, sender: Sender<T>, msg: T, ) -> i32
Add a menu item along with an emit (sender and message). The characters “&”, “/”, “\”, and “_” (underscore) are treated as special characters in the label string. The “&” character specifies that the following character is an accelerator and will be underlined. The “\” character is used to escape the next character in the string. Labels starting with the “_” (underscore) character cause a divider to be placed after that menu item.
fn insert_emit<T>(
&mut self,
idx: i32,
label: &str,
shortcut: Shortcut,
flag: MenuFlag,
sender: Sender<T>,
msg: T,
) -> i32
fn insert_emit<T>( &mut self, idx: i32, label: &str, shortcut: Shortcut, flag: MenuFlag, sender: Sender<T>, msg: T, ) -> i32
Inserts a menu item along with an emit (sender and message). The characters “&”, “/”, “\”, and “_” (underscore) are treated as special characters in the label string. The “&” character specifies that the following character is an accelerator and will be underlined. The “\” character is used to escape the next character in the string. Labels starting with the “_” (underscore) character cause a divider to be placed after that menu item.
fn add_choice(&mut self, text: &str) -> i32
fn add_choice(&mut self, text: &str) -> i32
Adds a simple text option to the Choice and MenuButton
widgets.
The characters “&”, “/”, “\”, “|”, and “_” (underscore) are treated as special characters in the label string. The “&” character specifies that the following character is an accelerator and will be underlined.
The “\” character is used to escape the next character in the string. Labels starting with the “_” (underscore) character cause a divider to be placed after that menu item.
fn set_value(&mut self, v: i32) -> bool
fn set_value(&mut self, v: i32) -> bool
Set index into menu of the last item chosen,return true if the new value is different than the old one
fn clear(&mut self)
fn clear(&mut self)
Clears the items in a menu, effectively deleting them.
Clears a submenu by index
§Errors
Errors on failure to clear the submenu, failure returns an FltkErrorKind::FailedOperation
unsafe fn unsafe_clear(&mut self)
unsafe fn unsafe_clear(&mut self)
Clears the items in a menu, effectively deleting them, and recursively force-cleans capturing callbacks
§Safety
Deletes user_data
and any captured objects in the callback
fn end(&mut self)
fn end(&mut self)
End the menu
fn set_down_frame(&mut self, f: FrameType)
fn set_down_frame(&mut self, f: FrameType)
Set the down_box
of the widget
fn down_frame(&self) -> FrameType
fn down_frame(&self) -> FrameType
Get the down frame type of the widget
fn global(&mut self)
fn global(&mut self)
Make a menu globally accessible from any window
Get the menu element
Set the menu element
§Safety
The MenuItem must be in a format recognized by FLTK (Empty CMenuItem after submenus and at the end of the menu)
fn item_pathname(&self, item: Option<&MenuItem>) -> Result<String, FltkError> ⓘ
fn item_pathname(&self, item: Option<&MenuItem>) -> Result<String, FltkError> ⓘ
Get an item’s pathname
Set the menu’s popup frame type
Get the menu’s popup frame type
fn prev_mvalue(&self) -> Option<MenuItem> ⓘ
fn prev_mvalue(&self) -> Option<MenuItem> ⓘ
Get the previously selected menu item