diff --git a/nih_plug_iced/src/widgets/param_slider.rs b/nih_plug_iced/src/widgets/param_slider.rs index b00f4136..fb0c9580 100644 --- a/nih_plug_iced/src/widgets/param_slider.rs +++ b/nih_plug_iced/src/widgets/param_slider.rs @@ -235,8 +235,6 @@ impl<'a, P: Param> Widget for ParamSlider<'a, P> { clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, ParamMessage>, ) -> event::Status { - let bounds = layout.bounds(); - // The pressence of a value in `self.state.text_input_value` indicates that the field should // be focussed. The field handles defocussing by itself // FIMXE: This is super hacky, I have no idea how you can reuse the text input widget @@ -298,6 +296,15 @@ impl<'a, P: Param> Widget for ParamSlider<'a, P> { return event::Status::Captured; } + // Compensate for the border when handling these events + let bounds = layout.bounds(); + let bounds = Rectangle { + x: bounds.x + BORDER_WIDTH, + y: bounds.y + BORDER_WIDTH, + width: bounds.width - (BORDER_WIDTH * 2.0), + height: bounds.height - (BORDER_WIDTH * 2.0), + }; + match event { Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) | Event::Touch(touch::Event::FingerPressed { .. }) => {