pub struct NumberSelect2 {
pub handle: ControlHandle,
data: Rc<RefCell<NumberSelectData>>,
edit: TextInput,
btn_up: Button,
btn_down: Button,
notice: Notice,
handler: Option<RawEventHandler>,
edit_handler: Option<RawEventHandler>,
}
Expand description
Fork of [nwg::NumberSelect
] that has some improvements.
§Differences
- Up and Down arrow keys will increment and decrement the number.
- Scroll events on the select control will increment or decrement the number.
- Manual text edits in the field will be validated and used to update the number data.
- Event that will be used whenever the number data is changed by the UI.
- Listen to
OnNotice
event to see changes.
- Listen to
§Original docs
A NumberSelect control is a pair of arrow buttons that the user can click to increment or decrement a value. NumberSelect is implemented as a custom control because the one provided by winapi really sucks.
Requires the number-select
feature.
Builder parameters:
parent
: Required. The number select parent container.value
: The default value of the number selectsize
: The number select size.position
: The number select position.enabled
: If the number select can be used by the user. It also has a grayed out look if disabled.flags
: A combination of the NumberSelectFlags values.font
: The font used for the number select text
Control events:
MousePress(_)
: Generic mouse press events on the buttonOnMouseMove
: Generic mouse mouse event
use virtual_desktop_manager::nwg_ext;
fn build_number_select(num_select: &mut nwg_ext::NumberSelect2, window: &nwg::Window, font: &nwg::Font) {
nwg_ext::NumberSelect2::builder()
.font(Some(font))
.parent(window)
.build(num_select);
}
Fields§
§handle: ControlHandle
§data: Rc<RefCell<NumberSelectData>>
§edit: TextInput
§btn_up: Button
§btn_down: Button
§notice: Notice
§handler: Option<RawEventHandler>
§edit_handler: Option<RawEventHandler>
Implementations§
Source§impl NumberSelect2
impl NumberSelect2
pub fn builder<'a>() -> NumberSelectBuilder<'a>
Sourcepub fn data(&self) -> NumberSelectData
pub fn data(&self) -> NumberSelectData
Returns inner data specifying the possible input of a number select See NumberSelectData for the possible values
Sourcepub fn set_data(&self, v: NumberSelectData)
pub fn set_data(&self, v: NumberSelectData)
Sets the inner data specifying the possible input of a number select. Also update the value display. See NumberSelectData for the possible values
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 control 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§
Source§impl Default for NumberSelect2
impl Default for NumberSelect2
Source§fn default() -> NumberSelect2
fn default() -> NumberSelect2
Source§impl Drop for NumberSelect2
impl Drop for NumberSelect2
Source§impl From<&NumberSelect2> for ControlHandle
impl From<&NumberSelect2> for ControlHandle
Source§fn from(control: &NumberSelect2) -> Self
fn from(control: &NumberSelect2) -> Self
Source§impl From<&mut NumberSelect2> for ControlHandle
impl From<&mut NumberSelect2> for ControlHandle
Source§fn from(control: &mut NumberSelect2) -> Self
fn from(control: &mut NumberSelect2) -> Self
Source§impl PartialEq<ControlHandle> for NumberSelect2
impl PartialEq<ControlHandle> for NumberSelect2
Source§impl PartialEq<NumberSelect2> for ControlHandle
impl PartialEq<NumberSelect2> for ControlHandle
Auto Trait Implementations§
impl !Freeze for NumberSelect2
impl !RefUnwindSafe for NumberSelect2
impl !Send for NumberSelect2
impl !Sync for NumberSelect2
impl Unpin for NumberSelect2
impl !UnwindSafe for NumberSelect2
Blanket Implementations§
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
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
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Source§impl<T> DynWithDefault for T
impl<T> DynWithDefault for T
Source§fn with_default_mut(
&mut self,
f: &mut dyn FnMut(&mut dyn DynWithDefault, &mut (dyn Any + 'static)),
)
fn with_default_mut( &mut self, f: &mut dyn FnMut(&mut dyn DynWithDefault, &mut (dyn Any + 'static)), )
self
and the second argument
is the new temporary default value. The callback can then modify the
value as needed.Source§fn clear_and_inspect_old(
&mut self,
f: &mut dyn FnMut(&mut dyn DynWithDefault, &mut (dyn Any + 'static)),
)
fn clear_and_inspect_old( &mut self, f: &mut dyn FnMut(&mut dyn DynWithDefault, &mut (dyn Any + 'static)), )
self
to a new default value and inspect the previous value as the
second argument to the callback.fn clear(&mut self)
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.