Describe the bug
If user presses and holds (using a mouse) on a spin control button with set range, it stops before the limit. For example range is (0,100). Pressing up button (using mouse) continuously from 0 will have it stop at 61 instead of at 100. Pressing up is ignored by later clicks. Starting from 100 and pressing down, results in similar behavior where it stops at 39 and pressing down again is ignored. It seems that wxEVT_SPIN* events are no longer generating when this case occurs.
This was replicated on wxSpin with style "wxSP_VERTICAL | wxSP_ARROW_KEYS". Issue is not encountered if wxSP_WRAP is set as style. This was replicated in Win 10 and Win 11 using wxWidgets 3.1.7 release zip. This issue does not occur on wxWidgets 3.1.0.
Expected vs observed behaviour
If I set range of wxSpin to (0, 100), pressing and holding at the buttons should stop at 0 and 100. Actual is 39(minimum) and 61 (maximum). Issue does not occur with normal single clicks.
Patch or snippet allowing to reproduce the problem
I attached modified minimal.cpp (Modified Minimal sample application) that can replicate the issue.
minimal.txt
To Reproduce
Steps to reproduce the behaviour, please make them
as detailed as possible, e.g.
Platform and version information
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I could not reproduce with the master using the widgets sample on Windows 10 21H2 build 19044.1766.

Works as expected going down as well.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Ooops, I only now realized that the issue is about wxSpinButton and not wxSpinCtrl, as the OP used the ambiguous "wxSpin".
Still, in the sample, the button seems to work as well, although there is a couple of odd messages logged when hitting 10:

—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks for testing! I guess this is due to doing something in the attached minimal.cpp, as it seems to do quite a few strange things.
@guzmanpaco Can you explain what are you doing there and why? Also, attaching diffs to the sample (minimal one in this case) is strongly preferred to attaching the whole files.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I also tried with a patch to the minimal sample
diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp index 470e765423..1a91974a95 100644 --- a/samples/minimal/minimal.cpp +++ b/samples/minimal/minimal.cpp @@ -26,6 +26,8 @@ #include "wx/wx.h" #endif +#include "wx/spinbutt.h" + // ---------------------------------------------------------------------------- // resources // ---------------------------------------------------------------------------- @@ -175,6 +177,20 @@ MyFrame::MyFrame(const wxString& title) CreateStatusBar(2); SetStatusText("Welcome to wxWidgets!"); #endif // wxUSE_STATUSBAR + + wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); + + wxSpinButton* spinBtn = new wxSpinButton(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_VERTICAL | wxSP_ARROW_KEYS); + spinBtn->SetValue(0); + spinBtn->SetRange(0, 100); + spinBtn->Bind(wxEVT_SPIN, [this](wxSpinEvent& e) { wxLogMessage("wxEVT_SPIN: position = %d", e.GetPosition()); }); + + wxTextCtrl* logCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH2); + wxLog::SetActiveTarget(new wxLogTextCtrl(logCtrl)); + + mainSizer->Add(spinBtn, wxSizerFlags().Border()); + mainSizer->Add(logCtrl, wxSizerFlags(1).Expand().Border()); + SetSizer(mainSizer); }
I have also skimmed the not-actually-a-minimal example provided by @guzmanpaco. The code there for some reason changes the spin button value in its spin event handler. Does not seem correct to me. I would also generally advise against changing focus from inside event handlers like these (e.g., where mouse is very involved).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks a lot for taking time to test this. I agree that this is probably due to changing the values in the control and/or focus in OP's code, which is not recommended at all and not supported.
Please try to provide a really minimal patch if you can isolate the problem further, but I think you will just find that you're doing something wrong in your code (which, again, is not really obvious to understand).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Closed #22537 as not planned.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()