Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #4014 Issue #4016

Closed
rustbasic opened this issue Feb 10, 2024 · 2 comments
Closed

Update #4014 Issue #4016

rustbasic opened this issue Feb 10, 2024 · 2 comments
Labels
bug Something is broken

Comments

@rustbasic
Copy link
Contributor

rustbasic commented Feb 10, 2024

@emilk

#4014 Even after update, the result is still the same. Try running the example below. In 'if clicked()' the value is 0.0.


Reference :

When I checked again, clicked() also seems to work well.
However, May be it seems that the value has already disappeared in if clicked().

use eframe::egui::*;

fn main() -> Result<(), eframe::Error> {
    let options = eframe::NativeOptions {
        viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
        ..Default::default()
    };

    eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.heading("My egui Application");

            let (response, _painter) =
                ui.allocate_painter(vec2(300.0, 150.0), Sense::click());
            let clicked_pos = response.interact_pointer_pos();
            if response.clicked() {
                let text = format!("clicked_pos: {:?}", clicked_pos.unwrap_or(pos2(0.0, 0.0)));
                ui.label(RichText::new(text.clone()).color(Color32::LIGHT_RED));
                ui.label(RichText::new(text.clone()).color(Color32::LIGHT_RED));
                ui.label(RichText::new(text.clone()).color(Color32::LIGHT_RED));
            }
            if response.is_pointer_button_down_on() {
                let text = format!("down_pos: {:?}", clicked_pos.unwrap_or(pos2(0.0, 0.0)));
                ui.label(text);
            }

            // let clicked_pos = response.interact_pointer_pos();
            // let text = format!("clicked_pos: {:?}", clicked_pos.unwrap_or(pos2(0.0, 0.0)));
            // ui.label(text);
        });
    })
}
@rustbasic rustbasic added the bug Something is broken label Feb 10, 2024
@rustbasic rustbasic changed the title Update #3999 Issue Update #4014 Issue Feb 10, 2024
@emilk
Copy link
Owner

emilk commented Feb 10, 2024

I tested this:

            let (response, painter) =
                ui.allocate_painter(egui::vec2(300.0, 150.0), egui::Sense::click());
            painter.rect_filled(response.rect, 2.0, egui::Color32::BLACK);
            let clicked_pos = response.interact_pointer_pos();
            if response.clicked() {
                eprintln!("clicked_pos: {clicked_pos:?}");
            }
            if response.is_pointer_button_down_on() {
                eprintln!("down_pos: {clicked_pos:?}");
            }

and it works as expected on main

@emilk emilk closed this as completed Feb 10, 2024
@RomainMazB
Copy link

Faced this in 2.6.0, can confirm it work as expected on 2.6.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants