mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -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:
@@ -27,7 +27,7 @@ pub fn toggle(ui: &mut egui::Ui, on: &mut bool) -> egui::Response {
|
||||
let (rect, response) = ui.allocate_exact_size(desired_size, egui::Sense::click());
|
||||
|
||||
// 3. Interact: Time to check for clicks!.
|
||||
if response.clicked {
|
||||
if response.clicked() {
|
||||
*on = !*on;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ pub fn toggle(ui: &mut egui::Ui, on: &mut bool) -> egui::Response {
|
||||
fn toggle_compact(ui: &mut egui::Ui, on: &mut bool) -> egui::Response {
|
||||
let desired_size = ui.style().spacing.interact_size;
|
||||
let (rect, response) = ui.allocate_exact_size(desired_size, egui::Sense::click());
|
||||
*on ^= response.clicked; // toggle if clicked
|
||||
*on ^= response.clicked(); // toggle if clicked
|
||||
|
||||
let how_on = ui.ctx().animate_bool(response.id, *on);
|
||||
let visuals = ui.style().interact(&response);
|
||||
|
||||
Reference in New Issue
Block a user