Struct native_windows_gui::Button
source · [−]pub struct Button {
pub handle: ControlHandle,
}
Expand description
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.ex_flags
: A combination of win32 window extended flags. Unlikeflags
, ex_flags must be used straight from winapifont
: 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: ControlHandle
Implementations
sourceimpl Button
impl Button
pub fn builder<'a>() -> ButtonBuilder<'a>
sourcepub fn set_bitmap<'a>(&self, image: Option<&'a Bitmap>)
pub fn set_bitmap<'a>(&self, image: Option<&'a Bitmap>)
Sets the bitmap image of the button. Replace the current bitmap or icon.
Set image
to None
to remove the image
sourcepub fn set_icon<'a>(&self, image: Option<&'a Icon>)
pub fn set_icon<'a>(&self, image: Option<&'a Icon>)
Sets the bitmap image of the button. Replace the current bitmap or icon.
Set image
to None
to remove the image
sourcepub fn image<'a>(&self, bitmap: &mut Option<Bitmap>, icon: &mut Option<Icon>)
pub fn image<'a>(&self, bitmap: &mut Option<Bitmap>, icon: &mut Option<Icon>)
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
sourcepub fn enabled(&self) -> bool
pub fn enabled(&self) -> bool
Returns true if the control user can interact with the control, return false otherwise
sourcepub fn set_enabled(&self, v: bool)
pub fn set_enabled(&self, v: bool)
Enable or disable the control
sourcepub fn visible(&self) -> bool
pub fn visible(&self) -> bool
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))
sourcepub fn set_visible(&self, v: bool)
pub fn set_visible(&self, v: bool)
Show or hide the control to the user
sourcepub fn set_position(&self, x: i32, y: i32)
pub fn set_position(&self, x: i32, y: i32)
Sets the position of the button in the parent window
sourcepub fn class_name(&self) -> &'static str
pub fn class_name(&self) -> &'static str
Winapi class name used during control creation
sourcepub fn forced_flags(&self) -> u32
pub fn forced_flags(&self) -> u32
Winapi flags required by the control
Trait Implementations
sourceimpl From<&Button> for ControlHandle
impl From<&Button> for ControlHandle
sourceimpl From<&mut Button> for ControlHandle
impl From<&mut Button> for ControlHandle
sourceimpl PartialEq<Button> for Button
impl PartialEq<Button> for Button
sourceimpl PartialEq<Button> for ControlHandle
impl PartialEq<Button> for ControlHandle
sourceimpl PartialEq<ControlHandle> for Button
impl PartialEq<ControlHandle> for Button
sourcefn eq(&self, other: &ControlHandle) -> bool
fn eq(&self, other: &ControlHandle) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
impl Eq for Button
impl StructuralEq for Button
impl StructuralPartialEq for Button
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more