Never get wxEVT_MOUSEWHEEL on wxSlider (Issue #25819)

22 views
Skip to first unread message

Bradley Whited

unread,
Sep 19, 2025, 8:06:13 PM (5 days ago) Sep 19
to wx-...@googlegroups.com, Subscribed
esotericpig created an issue (wxWidgets/wxWidgets#25819)

Description

Bug description:

wxSlider never receives events for wxEVT_MOUSEWHEEL.

Essentially, I want to disable using the mouse wheel over my Sliders.

This is because my Sliders are inside of a Scrolled window, so when you scroll the window, it then scrolls the sliders as you pass over them, which causes a bad UX.

Is this possible some other way?

Patch or snippet allowing to reproduce the problem:

minimal.cpp

Note that even with only slider->Bind() and the other Binds commented out, it still doesn't get the event (no wxPuts called).

@@ -175,6 +175,32 @@
     CreateStatusBar(2);
     SetStatusText("Welcome to wxWidgets!");
 #endif // wxUSE_STATUSBAR
+
+    auto* panel = new wxPanel{this};
+    auto* sizer = new wxBoxSizer{wxVERTICAL};
+
+    auto* slider = new wxSlider{panel,wxID_ANY,25,1,50,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL};
+
+    wxPuts("binding mouse wheel to slider");
+    slider->Bind(wxEVT_MOUSEWHEEL,[](wxMouseEvent&) {
+        // this never gets called
+        wxPuts("==> mouse wheel on slider?");
+    });
+
+    Bind(wxEVT_MOUSEWHEEL,[](wxMouseEvent&) {
+        // this never gets called
+       wxPuts("[frame] mouse wheel");
+    });
+    panel->Bind(wxEVT_MOUSEWHEEL,[](wxMouseEvent&) {
+       // this only gets called when on the panel and not over the child slider
+       wxPuts("[panel] mouse wheel");
+    });
+
+    sizer->Add(slider,0,wxALL | wxEXPAND,5);
+
+    panel->SetSizer(sizer);
+    sizer->Layout();
+    sizer->Fit(panel);
 }

Platform and version information

  • wxWidgets version you use: 3.3.1 (using latest one from vcpkg)
  • wxWidgets port you use: wxGTK
  • OS and its version: Ubuntu 22.04 LTS
    • GTK version: 3.24.33
    • Which GDK backend is used: X11
    • Desktop environment: GNOME


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25819@github.com>

oneeyeman1

unread,
Sep 20, 2025, 1:04:15 AM (5 days ago) Sep 20
to wx-...@googlegroups.com, Subscribed
oneeyeman1 left a comment (wxWidgets/wxWidgets#25819)

@esotericpig ,
Why not use wxEVT_SCROLL and just do nothing there?

Thank you.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25819/3314572461@github.com>

Bradley Whited

unread,
Sep 20, 2025, 4:32:40 PM (4 days ago) Sep 20
to wx-...@googlegroups.com, Subscribed
esotericpig left a comment (wxWidgets/wxWidgets#25819)

@oneeyeman1

Thanks for the reply. I tried this, but even with an empty function, I can continue to scroll the slider with the mouse wheel. I even tried event.Skip(false); but doesn't work. How can I cancel the mouse wheel event?

It does correctly print "on scroll" to stdout, so I'm getting the event.

Also, it would be nice to have a wxEVT_SCROLL or similar that binds to all so that I don't have to create an event table [I prefer using Bind()], not sure if that exists?

Here's what I tried:

class MyFrame : public wxFrame
{
public:
    //...

    wxSlider* slider{};

    void OnScroll(wxScrollEvent& event) {
        // do nothing
        wxPuts("on scroll");
    }
}

enum
{
    //...

    Minimal_Slider = 1,
};

wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
    //...

    EVT_COMMAND_SCROLL(Minimal_Slider, MyFrame::OnScroll)
    EVT_SCROLL(MyFrame::OnScroll)
wxEND_EVENT_TABLE()


MyFrame::MyFrame(const wxString& title)
       : wxFrame(nullptr, wxID_ANY, title)
{
    //...

    slider = new wxSlider{panel,Minimal_Slider,25,1,50,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL};

    //...
}


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25819/3315242719@github.com>

oneeyeman1

unread,
Sep 20, 2025, 4:55:20 PM (4 days ago) Sep 20
to wx-...@googlegroups.com, Subscribed
oneeyeman1 left a comment (wxWidgets/wxWidgets#25819)

@esotericpig ,
I just checked the sources and GTK docs.

It looks like this functionality is not supported (yet?)

I'm not sure if this is because you cant make it work cross-platform or...

Thank you.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25819/3315251865@github.com>

Reply all
Reply to author
Forward
0 new messages