[−][src]Struct native_windows_gui::Button
A push button is a rectangle containing an application-defined text label.
Use ImageButton if you need to have a button that ONLY contains an icon or a bitmap.
Button is not behind any features.
Builder parameters:
parent: Required. The button parent container.text: The button text.size: The button size.position: The button position.enabled: If the button can be used by the user. It also has a grayed out look if disabled.flags: A combination of the ButtonFlags values.font: The font used for the button textbitmap: A bitmap to display next to the button text. If this value is set, icon is ignored.icon: An icon to display next to the button textfocus: The control receive focus after being created
Control events:
OnButtonClick: When the button is clicked once by the userOnButtonDoubleClick: When the button is clicked twice rapidly by the userMousePress(_): Generic mouse press events on the buttonOnMouseMove: Generic mouse mouse eventOnMouseWheel: Generic mouse wheel event
use native_windows_gui as nwg; fn build_button(button: &mut nwg::Button, window: &nwg::Window, font: &nwg::Font) { nwg::Button::builder() .text("Hello") .flags(nwg::ButtonFlags::VISIBLE) .font(Some(font)) .parent(window) .build(button); }
Fields
handle: ControlHandleImplementations
impl Button[src]
pub fn builder<'a>() -> ButtonBuilder<'a>[src]
pub fn click(&self)[src]
Simulate a user click
pub fn set_bitmap<'a>(&self, image: Option<&'a Bitmap>)[src]
Sets the bitmap image of the button. Replace the current bitmap or icon.
Set image to None to remove the image
pub fn set_icon<'a>(&self, image: Option<&'a Icon>)[src]
Sets the bitmap image of the button. Replace the current bitmap or icon.
Set image to None to remove the image
pub fn image<'a>(&self, bitmap: &mut Option<Bitmap>, icon: &mut Option<Icon>)[src]
Returns the current image in the button.
If the button has a bitmap, the value will be returned in bitmap
If the button has a icon, the value will be returned in icon
pub fn font(&self) -> Option<Font>[src]
Returns the font of the control
pub fn set_font(&self, font: Option<&Font>)[src]
Sets the font of the control
pub fn focus(&self) -> bool[src]
Returns true if the control currently has the keyboard focus
pub fn set_focus(&self)[src]
Sets the keyboard focus on the button.
pub fn enabled(&self) -> bool[src]
Returns true if the control user can interact with the control, return false otherwise
pub fn set_enabled(&self, v: bool)[src]
Enable or disable the control
pub fn visible(&self) -> bool[src]
Returns true if the control is visible to the user. Will return true even if the control is outside of the parent client view (ex: at the position (10000, 10000))
pub fn set_visible(&self, v: bool)[src]
Show or hide the control to the user
pub fn size(&self) -> (u32, u32)[src]
Returns the size of the button in the parent window
pub fn set_size(&self, x: u32, y: u32)[src]
Sets the size of the button in the parent window
pub fn position(&self) -> (i32, i32)[src]
Returns the position of the button in the parent window
pub fn set_position(&self, x: i32, y: i32)[src]
Sets the position of the button in the parent window
pub fn text(&self) -> String[src]
Returns the button label
pub fn set_text<'a>(&self, v: &'a str)[src]
Sets the button label
pub fn class_name(&self) -> &'static str[src]
Winapi class name used during control creation
pub fn flags(&self) -> u32[src]
Winapi base flags used during window creation
pub fn forced_flags(&self) -> u32[src]
Winapi flags required by the control
Trait Implementations
impl Default for Button[src]
impl Drop for Button[src]
impl Eq for Button[src]
impl<'_> From<&'_ Button> for ControlHandle[src]
impl PartialEq<Button> for Button[src]
impl PartialEq<Button> for ControlHandle[src]
impl PartialEq<ControlHandle> for Button[src]
fn eq(&self, other: &ControlHandle) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl StructuralEq for Button[src]
impl StructuralPartialEq for Button[src]
Auto Trait Implementations
impl RefUnwindSafe for Button
impl !Send for Button
impl !Sync for Button
impl Unpin for Button
impl UnwindSafe for Button
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
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>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,