disabled button sends EVT_BUTTON events

Bug #1036415 reported by Felix Wohlfrom
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
wxwidgets2.8 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Hello,

I recently run in a really weird behavior of wxwidgets.

I got an wxDialog (but it also works with wxFrame, see example below) in which I had a button and a wxTextCtrl.
The button is disabled on frame creation, but set as default.
If I click the return key, nothing happens as expected.
But if I select the textCtrl and then press return, the button event will be fired.
If I compile the exact same code on windows, no events are generated as expected.
My Version of wxWidgets is 2.8.12.1-6ubuntu2 on ubuntu 11.04 amd64.

Test code, compiled with "g++ Test.cpp `wx-config --libs --cxxflags` -o test":

#include <wx/wx.h>

class TestWindow: public wxFrame
{
 public:
  TestWindow();

 private:
  void OnOkClick(wxCommandEvent& WXUNUSED(e));
  DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(TestWindow, wxWindow)
 EVT_BUTTON(wxID_OK, TestWindow::OnOkClick)
END_EVENT_TABLE()

TestWindow::TestWindow():
wxFrame(NULL, wxID_ANY, _T("Test"))
{
 wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
 wxTextCtrl* textctrl = new wxTextCtrl(this, wxID_ANY);
 wxButton* button = new wxButton(this, wxID_OK, _("&Press me"));
 button->SetDefault();
 button->Enable(false);

 sizer->Add(textctrl);
 sizer->Add(button);
 this->SetSizer(sizer);

 this->Layout();
}

void TestWindow::OnOkClick(wxCommandEvent& WXUNUSED(e))
{
 std::cout << "This shouldn't happen" << std::endl;
}

class Test: public wxApp
{
 private:
  bool OnInit();
};

DECLARE_APP(Test)

IMPLEMENT_APP(Test)

bool Test::OnInit()
{
 TestWindow* win = new TestWindow();
 return win->Show();
}

summary: - disabled button can be pressed
+ disabled button sends EVT_BUTTON events
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.