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?
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); }
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@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.
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.
@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.