Control: ui.click / ui.drag hold their modifiers for the whole gesture
egui takes i.modifiers from ModifiersChanged events, not from the modifiers on a pointer event, so a control-channel Shift-click arrived as a plain click (e.g. Shift-click in the Timeline replaced the selection instead of adding). ui.click and ui.drag now queue ModifiersChanged before the gesture and clear it after. The synthetic-input feeding moves into EffectcraftApp::feed_synthetic so it can be tested; the new tests fail without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ea25e402b1
commit
726d7e47a1
+20
-13
@@ -381,6 +381,25 @@ impl EffectcraftApp {
|
||||
v
|
||||
}
|
||||
|
||||
/// Feed this frame's share of the queued synthetic input (control channel `ui.click`,
|
||||
/// `ui.drag`…) into `raw_input`. Pointer events go one per frame so egui sees press → moves
|
||||
/// → release as a real gesture.
|
||||
pub fn feed_synthetic(&mut self, raw_input: &mut egui::RawInput) {
|
||||
if !self.synthetic.is_empty() {
|
||||
// Pointer events go one per frame so egui sees press → moves → release as a real drag.
|
||||
let pointer = |e: &egui::Event| matches!(e, egui::Event::PointerMoved(_) | egui::Event::PointerButton { .. } | egui::Event::MouseWheel { .. });
|
||||
let n = if pointer(&self.synthetic[0]) {
|
||||
1
|
||||
} else {
|
||||
self.synthetic
|
||||
.iter()
|
||||
.position(|e| pointer(e) || matches!(e, egui::Event::Key { pressed: false, .. }))
|
||||
.map_or(self.synthetic.len(), |i| if pointer(&self.synthetic[i]) { i.max(1) } else { i + 1 })
|
||||
};
|
||||
raw_input.events.extend(self.synthetic.drain(..n));
|
||||
}
|
||||
}
|
||||
|
||||
/// Show panel `p` (opening it in its usual place if it is closed), bring it to the front and
|
||||
/// give it the focus: Window ▸ <panel>.
|
||||
pub fn show_panel(&mut self, p: PanelKind) {
|
||||
@@ -1393,19 +1412,7 @@ impl eframe::App for EffectcraftApp {
|
||||
}
|
||||
|
||||
fn raw_input_hook(&mut self, _ctx: &egui::Context, raw_input: &mut egui::RawInput) {
|
||||
if !self.synthetic.is_empty() {
|
||||
// Pointer events go one per frame so egui sees press → moves → release as a real drag.
|
||||
let pointer = |e: &egui::Event| matches!(e, egui::Event::PointerMoved(_) | egui::Event::PointerButton { .. } | egui::Event::MouseWheel { .. });
|
||||
let n = if pointer(&self.synthetic[0]) {
|
||||
1
|
||||
} else {
|
||||
self.synthetic
|
||||
.iter()
|
||||
.position(|e| pointer(e) || matches!(e, egui::Event::Key { pressed: false, .. }))
|
||||
.map_or(self.synthetic.len(), |i| if pointer(&self.synthetic[i]) { i.max(1) } else { i + 1 })
|
||||
};
|
||||
raw_input.events.extend(self.synthetic.drain(..n));
|
||||
}
|
||||
self.feed_synthetic(raw_input);
|
||||
}
|
||||
|
||||
fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
|
||||
Reference in New Issue
Block a user