mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Multiple mouse button support (#135)
Add support for primary, secondary and middle mouse buttons. Also improve ability to click things in low FPS situations.
This introduces a lot of breaking changes:
Backends/integrations now pass mouse events via the even stream.
Response has an interface of mostly methods instead of public members.
input.mouse is now input.pointer and has new interface.
* Rename 'mouse' to 'pointer' everywhere (pointer = mouse or touch)
* Make Response::clicked and Response::double_clicked into methods
* Remove Response::active and add dragged() and interact_pointer_pos()
* Support multiple mouse buttons
* Make PointerState interface all methods
* Make most members of Response private
This commit is contained in:
@@ -73,7 +73,7 @@ impl epi::App for WrapApp {
|
||||
for (anchor, app) in self.apps.iter_mut() {
|
||||
if ui
|
||||
.selectable_label(self.selected_anchor == anchor, app.name())
|
||||
.clicked
|
||||
.clicked()
|
||||
{
|
||||
self.selected_anchor = anchor.to_owned();
|
||||
if frame.is_web() {
|
||||
@@ -86,7 +86,7 @@ impl epi::App for WrapApp {
|
||||
if false {
|
||||
// TODO: fix the overlap on small screens
|
||||
if let Some(seconds_since_midnight) = frame.info().seconds_since_midnight {
|
||||
if clock_button(ui, seconds_since_midnight).clicked {
|
||||
if clock_button(ui, seconds_since_midnight).clicked() {
|
||||
self.selected_anchor = "clock".to_owned();
|
||||
if frame.is_web() {
|
||||
ui.output().open_url = Some("#clock".to_owned());
|
||||
@@ -234,11 +234,11 @@ impl BackendPanel {
|
||||
if ui
|
||||
.button("📱 Phone Size")
|
||||
.on_hover_text("Resize the window to be small like a phone.")
|
||||
.clicked
|
||||
.clicked()
|
||||
{
|
||||
frame.set_window_size(egui::Vec2::new(375.0, 812.0)); // iPhone 12 mini
|
||||
}
|
||||
if ui.button("Quit").clicked {
|
||||
if ui.button("Quit").clicked() {
|
||||
frame.quit();
|
||||
}
|
||||
}
|
||||
@@ -275,7 +275,7 @@ impl BackendPanel {
|
||||
"Reset scale to native value ({:.1})",
|
||||
native_pixels_per_point
|
||||
))
|
||||
.clicked
|
||||
.clicked()
|
||||
{
|
||||
*pixels_per_point = native_pixels_per_point;
|
||||
}
|
||||
@@ -283,7 +283,7 @@ impl BackendPanel {
|
||||
});
|
||||
|
||||
// We wait until mouse release to activate:
|
||||
if ui.ctx().is_using_mouse() {
|
||||
if ui.ctx().is_using_pointer() {
|
||||
None
|
||||
} else {
|
||||
Some(*pixels_per_point)
|
||||
|
||||
Reference in New Issue
Block a user