pub struct Button {
pub enable_long_press: bool,
pub text: ArcStringMut,
/* private fields */
}
Expand description
A clickable button widget that emits actions when pressed, and when either released or clicked.
Fields§
§enable_long_press: bool
Set the long-press handling behavior of this button.
- If
false
(default), the button will ignore long-press events and will never emitButtonAction::LongPressed
.- Also, the button logic will not call
FingerUpEvent::was_tap()
to check if the button press was a short tap. This means that this button will consider itself to be clicked (and thus emit aButtonAction::Clicked
event) if the finger-up/release event occurs within the button area, regardless of how long the button was pressed down before it was released.
- Also, the button logic will not call
- If
true
, the button will respond to a long-press event by emittingButtonAction::LongPressed
, which can only occur on mobile platforms that support a native long press event.- Also, the button will only consider itself to be clicked
(and thus emit
ButtonAction::Clicked
) ifFingerUpEvent::was_tap()
returnstrue
, meaning that a long press did not occur and that the button was released over the button area within a short time frame (~0.5 seconds) after the initial down press.
- Also, the button will only consider itself to be clicked
(and thus emit
text: ArcStringMut
Implementations§
Source§impl Button
impl Button
Sourcepub fn clicked(&self, actions: &Actions) -> bool
pub fn clicked(&self, actions: &Actions) -> bool
Returns true
if this button was clicked.
See ButtonAction
for more details.
Sourcepub fn pressed(&self, actions: &Actions) -> bool
pub fn pressed(&self, actions: &Actions) -> bool
Returns true
if this button was pressed down.
See ButtonAction
for more details.
Sourcepub fn long_pressed(&self, actions: &Actions) -> bool
pub fn long_pressed(&self, actions: &Actions) -> bool
Returns true
if this button was long-pressed on.
Note that this does not mean the button has been released yet.
See ButtonAction
for more details.
Sourcepub fn released(&self, actions: &Actions) -> bool
pub fn released(&self, actions: &Actions) -> bool
Returns true
if this button was released, which is not considered to be clicked.
See ButtonAction
for more details.
Sourcepub fn clicked_modifiers(&self, actions: &Actions) -> Option<KeyModifiers>
pub fn clicked_modifiers(&self, actions: &Actions) -> Option<KeyModifiers>
Returns Some
(with active keyboard modifiers) if this button was clicked.
See ButtonAction
for more details.
Sourcepub fn pressed_modifiers(&self, actions: &Actions) -> Option<KeyModifiers>
pub fn pressed_modifiers(&self, actions: &Actions) -> Option<KeyModifiers>
Returns Some
(with active keyboard modifiers) if this button was pressed down.
See ButtonAction
for more details.
Sourcepub fn released_modifiers(&self, actions: &Actions) -> Option<KeyModifiers>
pub fn released_modifiers(&self, actions: &Actions) -> Option<KeyModifiers>
Returns Some
(with active keyboard modifiers) if this button was released,
which is not considered to be clicked.
See ButtonAction
for more details.