Add `PointerState::button_double_clicked()` and `PointerState::button_triple_clicked()`. (#1907)
Co-authored-by: eranfu <eranfu@tencent.com>
This commit is contained in:
parent
7c25a9238e
commit
38a67f8646
|
|
@ -18,6 +18,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui-w
|
||||||
* Added `Contex::request_repaint_after` ([#1694](https://github.com/emilk/egui/pull/1694)).
|
* Added `Contex::request_repaint_after` ([#1694](https://github.com/emilk/egui/pull/1694)).
|
||||||
* `ctrl-h` now acts like backspace in `TextEdit` ([#1812](https://github.com/emilk/egui/pull/1812)).
|
* `ctrl-h` now acts like backspace in `TextEdit` ([#1812](https://github.com/emilk/egui/pull/1812)).
|
||||||
* Added `RawInput::has_focus` which backends can set to indicate whether the UI as a whole has the keyboard focus ([#1859](https://github.com/emilk/egui/pull/1859)).
|
* Added `RawInput::has_focus` which backends can set to indicate whether the UI as a whole has the keyboard focus ([#1859](https://github.com/emilk/egui/pull/1859)).
|
||||||
|
* Added `PointerState::button_double_clicked()` and `PointerState::button_triple_clicked()` ([#1906](https://github.com/emilk/egui/issues/1906)).
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* MSRV (Minimum Supported Rust Version) is now `1.61.0` ([#1846](https://github.com/emilk/egui/pull/1846)).
|
* MSRV (Minimum Supported Rust Version) is now `1.61.0` ([#1846](https://github.com/emilk/egui/pull/1846)).
|
||||||
|
|
|
||||||
|
|
@ -750,6 +750,20 @@ impl PointerState {
|
||||||
.any(|event| matches!(event, &PointerEvent::Pressed { button: b, .. } if button == b))
|
.any(|event| matches!(event, &PointerEvent::Pressed { button: b, .. } if button == b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Was the button given double clicked this frame?
|
||||||
|
pub fn button_double_clicked(&self, button: PointerButton) -> bool {
|
||||||
|
self.pointer_events
|
||||||
|
.iter()
|
||||||
|
.any(|event| matches!(&event, PointerEvent::Released(Some(click)) if click.button == button && click.is_double()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Was the button given triple clicked this frame?
|
||||||
|
pub fn button_triple_clicked(&self, button: PointerButton) -> bool {
|
||||||
|
self.pointer_events
|
||||||
|
.iter()
|
||||||
|
.any(|event| matches!(&event, PointerEvent::Released(Some(click)) if click.button == button && click.is_triple()))
|
||||||
|
}
|
||||||
|
|
||||||
/// Was the primary button clicked this frame?
|
/// Was the primary button clicked this frame?
|
||||||
pub fn primary_clicked(&self) -> bool {
|
pub fn primary_clicked(&self) -> bool {
|
||||||
self.button_clicked(PointerButton::Primary)
|
self.button_clicked(PointerButton::Primary)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue