-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in switch when case has wxMessageBox() #24463
Comments
Please provide a way of reproducing the problem in a sample. With this diff: diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp
index 5f32257c6b..751de45266 100644
--- a/samples/minimal/minimal.cpp
+++ b/samples/minimal/minimal.cpp
@@ -175,6 +175,11 @@ MyFrame::MyFrame(const wxString& title)
CreateStatusBar(2);
SetStatusText("Welcome to wxWidgets!");
#endif // wxUSE_STATUSBAR
+
+ auto p = new wxPanel(this);
+ p->Bind(wxEVT_CHAR_HOOK, [](wxKeyEvent& event) {
+ wxLogMessage("Char hook: %d", event.GetKeyCode());
+ });
}
I don't see anything wrong, i.e. pressing either Also note that you should call |
I do use event.skip(). The code i showed you used wxMessageBox(), not wxLogMessage. I'm just trying to help you guys. |
Sorry, but I have no way of knowing it if your example code doesn't show it.
Needless to say, I don't see the bug with the same diff using
Thank you, but what really helps is following our bug reporting guidelines, and notably providing a complete self-contained example reproducing the problem. Could you please make one as explained there? |
In my first attempt at trying to catch keys, I think I found a bug. The first time I ran it, I had success catching the Tab key, which only popped up a message box to show the code worked. So, I got greedy and tried to catch both the Alt and the Ctrl keys. Here's what that code looked like:
Bind(wxEVT_CHAR_HOOK, &MyFrame::OnChar, this);
void MyFrame::OnChar(wxKeyEvent &event){
switch ( event.GetKeyCode() ) { case WXK_TAB: wxMessageBox("Tab key");break; case WXK_ALT: wxMessageBox("Alt key");break; case WXK_CONTROL: wxMessageBox("Ctrl key");break; } }
Without being too long-winded, hitting either the Alt key or Ctrl key made the switch statement loop through their respective wxMessageBoxes() 4 times. Without fail.
Linux Mint 21.3
wxWidgets-3.2.4
The text was updated successfully, but these errors were encountered: