Bugfix/drag window (#1108)
Call .drag_window() only after Left mouse btn clicked Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
parent
26be0ace1d
commit
0d00185d9f
3 changed files with 19 additions and 6 deletions
|
@ -38,10 +38,12 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w
|
||||||
### Fixed 🐛
|
### Fixed 🐛
|
||||||
* Context menu now respects the theme ([#1043](https://github.com/emilk/egui/pull/1043))
|
* Context menu now respects the theme ([#1043](https://github.com/emilk/egui/pull/1043))
|
||||||
* Plot `Orientation` was not public, although fields using this type were ([#1130](https://github.com/emilk/egui/pull/1130))
|
* Plot `Orientation` was not public, although fields using this type were ([#1130](https://github.com/emilk/egui/pull/1130))
|
||||||
|
* Fixed `enable_drag` for Windows ([#1108](https://github.com/emilk/egui/pull/1108)).
|
||||||
|
|
||||||
### Contributors 🙏
|
### Contributors 🙏
|
||||||
* [danielkeller](https://github.com/danielkeller): [#1050](https://github.com/emilk/egui/pull/1050).
|
* [danielkeller](https://github.com/danielkeller): [#1050](https://github.com/emilk/egui/pull/1050).
|
||||||
* [juancampa](https://github.com/juancampa): [#1147](https://github.com/emilk/egui/pull/1147).
|
* [juancampa](https://github.com/juancampa): [#1147](https://github.com/emilk/egui/pull/1147).
|
||||||
|
* [AlexxxRu](https://github.com/alexxxru): [#1108](https://github.com/emilk/egui/pull/1108).
|
||||||
|
|
||||||
|
|
||||||
## 0.16.1 - 2021-12-31 - Add back `CtxRef::begin_frame,end_frame`
|
## 0.16.1 - 2021-12-31 - Add back `CtxRef::begin_frame,end_frame`
|
||||||
|
|
|
@ -8,6 +8,7 @@ All notable changes to the `egui-winit` integration will be noted in this file.
|
||||||
* Replaced `std::time::Instant` with `instant::Instant` for WebAssembly compatability ([#1023](https://github.com/emilk/egui/pull/1023))
|
* Replaced `std::time::Instant` with `instant::Instant` for WebAssembly compatability ([#1023](https://github.com/emilk/egui/pull/1023))
|
||||||
* Shift-scroll will now result in horizontal scrolling on all platforms ([#1136](https://github.com/emilk/egui/pull/1136)).
|
* Shift-scroll will now result in horizontal scrolling on all platforms ([#1136](https://github.com/emilk/egui/pull/1136)).
|
||||||
* Require knowledge about max texture side (e.g. `GL_MAX_TEXTURE_SIZE`)) ([#1154](https://github.com/emilk/egui/pull/1154)).
|
* Require knowledge about max texture side (e.g. `GL_MAX_TEXTURE_SIZE`)) ([#1154](https://github.com/emilk/egui/pull/1154)).
|
||||||
|
* Fixed `enable_drag` for Windows. Now called only once just after left click ([#1108](https://github.com/emilk/egui/pull/1108)).
|
||||||
|
|
||||||
|
|
||||||
## 0.16.0 - 2021-12-29
|
## 0.16.0 - 2021-12-29
|
||||||
|
|
|
@ -193,6 +193,7 @@ pub struct EpiIntegration {
|
||||||
pub app: Box<dyn epi::App>,
|
pub app: Box<dyn epi::App>,
|
||||||
/// When set, it is time to quit
|
/// When set, it is time to quit
|
||||||
quit: bool,
|
quit: bool,
|
||||||
|
can_drag_window: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EpiIntegration {
|
impl EpiIntegration {
|
||||||
|
@ -227,6 +228,7 @@ impl EpiIntegration {
|
||||||
egui_winit: crate::State::new(max_texture_side, window),
|
egui_winit: crate::State::new(max_texture_side, window),
|
||||||
app,
|
app,
|
||||||
quit: false,
|
quit: false,
|
||||||
|
can_drag_window: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
slf.setup(window);
|
slf.setup(window);
|
||||||
|
@ -264,11 +266,17 @@ impl EpiIntegration {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_event(&mut self, event: &winit::event::WindowEvent<'_>) {
|
pub fn on_event(&mut self, event: &winit::event::WindowEvent<'_>) {
|
||||||
use winit::event::WindowEvent;
|
use winit::event::{ElementState, MouseButton, WindowEvent};
|
||||||
if *event == WindowEvent::CloseRequested {
|
|
||||||
self.quit = self.app.on_exit_event();
|
match event {
|
||||||
} else if *event == WindowEvent::Destroyed {
|
WindowEvent::CloseRequested => self.quit = self.app.on_exit_event(),
|
||||||
self.quit = true;
|
WindowEvent::Destroyed => self.quit = true,
|
||||||
|
WindowEvent::MouseInput {
|
||||||
|
button: MouseButton::Left,
|
||||||
|
state: ElementState::Pressed,
|
||||||
|
..
|
||||||
|
} => self.can_drag_window = true,
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.egui_winit.on_event(&self.egui_ctx, event);
|
self.egui_winit.on_event(&self.egui_ctx, event);
|
||||||
|
@ -291,7 +299,9 @@ impl EpiIntegration {
|
||||||
.egui_winit
|
.egui_winit
|
||||||
.handle_output(window, &self.egui_ctx, egui_output);
|
.handle_output(window, &self.egui_ctx, egui_output);
|
||||||
|
|
||||||
let app_output = self.frame.take_app_output();
|
let mut app_output = self.frame.take_app_output();
|
||||||
|
app_output.drag_window &= self.can_drag_window; // Necessary on Windows; see https://github.com/emilk/egui/pull/1108
|
||||||
|
self.can_drag_window = false;
|
||||||
|
|
||||||
if app_output.quit {
|
if app_output.quit {
|
||||||
self.quit = self.app.on_exit_event();
|
self.quit = self.app.on_exit_event();
|
||||||
|
|
Loading…
Reference in a new issue