From fc55a519fa45e9e4472109f52a016d9756be0a65 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 8 Oct 2022 15:48:18 +0200 Subject: [PATCH] Consume vizia ParamSlider events as appropriate --- nih_plug_vizia/src/widgets/param_slider.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nih_plug_vizia/src/widgets/param_slider.rs b/nih_plug_vizia/src/widgets/param_slider.rs index 51b7fd2e..55dce259 100644 --- a/nih_plug_vizia/src/widgets/param_slider.rs +++ b/nih_plug_vizia/src/widgets/param_slider.rs @@ -390,10 +390,12 @@ impl View for ParamSlider { } fn event(&mut self, cx: &mut EventContext, event: &mut Event) { - event.map(|param_slider_event, _| match param_slider_event { + event.map(|param_slider_event, meta| match param_slider_event { ParamSliderEvent::CancelTextInput => { self.text_input_active = false; cx.set_active(false); + + meta.consume(); } ParamSliderEvent::TextInput(string) => { if let Some(normalized_value) = @@ -405,10 +407,12 @@ impl View for ParamSlider { } self.text_input_active = false; + + meta.consume(); } }); - event.map(|window_event, _| match window_event { + event.map(|window_event, meta| match window_event { WindowEvent::MouseDown(MouseButton::Left) => { if cx.modifiers.alt() { // ALt+Click brings up a text entry dialog @@ -445,6 +449,8 @@ impl View for ParamSlider { ); } } + + meta.consume(); } WindowEvent::MouseDoubleClick(MouseButton::Left) => { // Ctrl+Click and double click should reset the parameter instead of initiating @@ -455,6 +461,8 @@ impl View for ParamSlider { unsafe { self.param_ptr.default_normalized_value() }, )); cx.emit(RawParamEvent::EndSetParameter(self.param_ptr)); + + meta.consume(); } WindowEvent::MouseUp(MouseButton::Left) => { if self.drag_active { @@ -463,6 +471,8 @@ impl View for ParamSlider { cx.set_active(false); cx.emit(RawParamEvent::EndSetParameter(self.param_ptr)); + + meta.consume(); } } WindowEvent::MouseMove(x, _y) => {