Fix sometimes not being able to click inside a combo box or popup menu

This commit is contained in:
Emil Ernerfeldt 2021-08-28 10:28:05 +02:00
parent 9bc95289cc
commit 56913a9ae9
3 changed files with 11 additions and 5 deletions

View file

@ -15,6 +15,7 @@ NOTE: [`eframe`](eframe/CHANGELOG.md), [`egui_web`](egui_web/CHANGELOG.md) and [
* Make minimum grid column width propagate properly. * Make minimum grid column width propagate properly.
* Make sure `TextEdit` contents expand to fill width if applicable. * Make sure `TextEdit` contents expand to fill width if applicable.
* `ProgressBar`: add a minimum width and fix for having it in an infinite layout. * `ProgressBar`: add a minimum width and fix for having it in an infinite layout.
* Fix sometimes not being able to click inside a combo box or popup menu.
## 0.14.0 - 2021-08-24 - Ui panels and bug fixes ## 0.14.0 - 2021-08-24 - Ui panels and bug fixes

View file

@ -168,7 +168,7 @@ impl Area {
pub(crate) struct Prepared { pub(crate) struct Prepared {
layer_id: LayerId, layer_id: LayerId,
state: State, state: State,
movable: bool, pub(crate) movable: bool,
enabled: bool, enabled: bool,
drag_bounds: Option<Rect>, drag_bounds: Option<Rect>,
} }
@ -337,10 +337,13 @@ impl Prepared {
state.pos += ctx.input().pointer.delta(); state.pos += ctx.input().pointer.delta();
} }
if let Some(bounds) = drag_bounds { // Important check - don't try to move e.g. a combobox popup!
state.pos = ctx.constrain_window_rect_to_area(state.rect(), bounds).min; if movable {
} else { if let Some(bounds) = drag_bounds {
state.pos = ctx.constrain_window_rect(state.rect()).min; state.pos = ctx.constrain_window_rect_to_area(state.rect(), bounds).min;
} else {
state.pos = ctx.constrain_window_rect(state.rect()).min;
}
} }
if (move_response.dragged() || move_response.clicked()) if (move_response.dragged() || move_response.clicked())

View file

@ -404,6 +404,8 @@ impl<'open> Window<'open> {
} }
content_inner content_inner
}; };
area.movable = possible.movable; // Tell it the truth
let full_response = area.end(ctx, area_content_ui); let full_response = area.end(ctx, area_content_ui);
let inner_response = InnerResponse { let inner_response = InnerResponse {