egui icon indicating copy to clipboard operation
egui copied to clipboard

Incorrect mouse position due to `ctx.set_pixels_per_point`

Open raui100 opened this issue 2 years ago • 3 comments

Describe the bug When setting a zoom factor with either ctx.set_pixels_per_point or ctx.set_zoom_factor the mouse position that is being "used in the GUI" doesn't match the mouse position that is shown on my monitor.

https://github.com/emilk/egui/assets/36443559/3d7ac0d6-5a3f-4199-8b8d-b63ca2ff1e57

To Reproduce

  1. Download the eframpe template (02ee968537e783e375a0e439426518bf91e762b6)
  2. add the following line:
impl TemplateApp {
    /// Called once before the first frame.
    pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
        // This is also where you can customize the look and feel of egui using
        // `cc.egui_ctx.set_visuals` and `cc.egui_ctx.set_fonts`.
+       cc.egui_ctx.set_zoom_factor(1.5);

        // Load previous app state (if any).
        // Note that you must enable the `persistence` feature for this to work.
        if let Some(storage) = cc.storage {
            return eframe::get_value(storage, eframe::APP_KEY).unwrap_or_default();
        }

        Default::default()
    }
}

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Chrome v121, Firefox v123

Additional context This had been working as expected with egui/eframe 0.23

raui100 avatar Feb 27 '24 11:02 raui100

I can reproduce this, but only in the web assembly version

TheZoq2 avatar Mar 14 '24 16:03 TheZoq2

On web the browser should be in control of the zoom level, so that's probably why this is only a problem on web

emilk avatar Mar 15 '24 06:03 emilk

I think #4260 fixes this. It's already released in 0.27.1

CrazyCraftix avatar Apr 02 '24 23:04 CrazyCraftix