pub struct Button(/* private fields */);
Available on crate feature
gui
only.Expand description
Native button control.
Implementations§
source§impl Button
impl Button
sourcepub fn new(parent: &impl GuiParent, opts: ButtonOpts) -> Self
pub fn new(parent: &impl GuiParent, opts: ButtonOpts) -> Self
Instantiates a new Button
object, to be created on the parent window
with
HWND::CreateWindowEx
.
§Panics
Panics if the parent window was already created – that is, you cannot
dynamically create a Button
in an event closure.
§Examples
use winsafe::{self as w, prelude::*, gui};
let wnd: gui::WindowMain; // initialized somewhere
let btn = gui::Button::new(
&wnd,
gui::ButtonOpts {
position: (10, 10),
text: "&Click me".to_owned(),
..Default::default()
},
);
sourcepub fn new_dlg(
parent: &impl GuiParent,
ctrl_id: u16,
resize_behavior: (Horz, Vert)
) -> Self
pub fn new_dlg( parent: &impl GuiParent, ctrl_id: u16, resize_behavior: (Horz, Vert) ) -> Self
Instantiates a new Button
object, to be loaded from a dialog resource
with HWND::GetDlgItem
.
§Panics
Panics if the parent dialog was already created – that is, you cannot
dynamically create a Button
in an event closure.
sourcepub fn trigger_click(&self)
pub fn trigger_click(&self)
Fires the click event for the button by sending a
bm::Click
message.
Trait Implementations§
source§impl GuiChildFocus for Button
impl GuiChildFocus for Button
source§fn focus(&self)
fn focus(&self)
In a raw, ordinary window, simply calls
HWND:SetFocus
. Read moresource§impl GuiNativeControl for Button
impl GuiNativeControl for Button
source§fn on_subclass(&self) -> &WindowEvents
fn on_subclass(&self) -> &WindowEvents
Exposes the subclass events. If at least one event exists, the control
will be
subclassed. Read more
source§impl GuiNativeControlEvents<ButtonEvents> for Button
impl GuiNativeControlEvents<ButtonEvents> for Button
source§fn on(&self) -> &ButtonEvents
fn on(&self) -> &ButtonEvents
Exposes the specific control events. Read more
source§impl GuiWindowText for Button
impl GuiWindowText for Button
source§fn set_text(&self, text: &str)
fn set_text(&self, text: &str)
Sets the text by calling
HWND::SetWindowText
.source§fn text(&self) -> String
fn text(&self) -> String
Retrieves the text by calling
HWND::GetWindowText
.impl Send for Button
Auto Trait Implementations§
impl Freeze for Button
impl !RefUnwindSafe for Button
impl !Sync for Button
impl Unpin for Button
impl !UnwindSafe for Button
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more