pub struct Edit(/* private fields */);
gui
only.Expand description
Native edit (text box) control.
Implementations§
Source§impl Edit
impl Edit
Sourcepub fn on_subclass(&self) -> &WindowEvents
pub fn on_subclass(&self) -> &WindowEvents
Exposes the subclass events. If at least one event exists, the control will be subclassed.
Note: Subclassing may impact performance, use with care.
§Panics
Panics if the control or the parent window are already created. Events must be set before control and parent window creation.
Sourcepub fn on(&self) -> &EditEvents
pub fn on(&self) -> &EditEvents
Exposes the specific control events.
§Panics
Panics if the control is already created. Events must be set before control creation.
Source§impl Edit
impl Edit
Sourcepub fn new(parent: &(impl GuiParent + 'static), opts: EditOpts) -> Self
pub fn new(parent: &(impl GuiParent + 'static), opts: EditOpts) -> Self
Instantiates a new Edit
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 an Edit
in an event closure.
§Examples
use winsafe::{self as w, prelude::*, gui};
let wnd: gui::WindowMain; // initialized somewhere
let txt = gui::Edit::new(
&wnd,
gui::EditOpts {
position: gui::dpi(10, 10),
width: gui::dpi_x(120),
..Default::default()
},
);
Sourcepub fn new_dlg(
parent: &(impl GuiParent + 'static),
ctrl_id: u16,
resize_behavior: (Horz, Vert),
) -> Self
pub fn new_dlg( parent: &(impl GuiParent + 'static), ctrl_id: u16, resize_behavior: (Horz, Vert), ) -> Self
Instantiates a new Edit
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 an Edit
in an event closure.
Sourcepub fn hide_balloon_tip(&self) -> SysResult<()>
pub fn hide_balloon_tip(&self) -> SysResult<()>
Hides any balloon tip by sending an
em::HideBalloonTip
message.
Sourcepub fn limit_text(&self, max_chars: Option<u32>)
pub fn limit_text(&self, max_chars: Option<u32>)
Limits the number of characters that can be type by sending an
em::SetLimitText
message.
Sourcepub fn set_selection(&self, start: i32, end: i32)
pub fn set_selection(&self, start: i32, end: i32)
Sets the selection range of the text by sending an
em::SetSel
message.
§Examples
Selecting all text in the control:
use winsafe::{self as w, prelude::*, gui};
let my_edit: gui::Edit; // initialized somewhere
my_edit.set_selection(0, -1);
Clearing the selection:
use winsafe::gui;
let my_edit: gui::Edit; // initialized somewhere
my_edit.set_selection(-1, -1);
Sourcepub fn set_text(&self, text: &str) -> SysResult<()>
pub fn set_text(&self, text: &str) -> SysResult<()>
Sets the text by calling
HWND::SetWindowText
.
Sourcepub fn show_ballon_tip(
&self,
title: &str,
text: &str,
icon: TTI,
) -> SysResult<()>
pub fn show_ballon_tip( &self, title: &str, text: &str, icon: TTI, ) -> SysResult<()>
Displays a balloon tip by sending an
em::ShowBalloonTip
message.
Sourcepub fn text(&self) -> SysResult<String>
pub fn text(&self) -> SysResult<String>
Retrieves the text by calling
HWND::GetWindowText
.