Page 1 of 1

wxMoveEvent and wxButton

Posted: Mon Sep 02, 2019 6:07 am
by Kvaz1r
According to the documentation wxMoveEvent is
holds information about wxTopLevelWindow move change events
then why it also generates the event for moving wxButton which isn't wxTopLevelWindow?

MCVE:

Code: Select all

#include <wx/wx.h>
#include <wx/dataview.h>

class MyFrame : public wxFrame
{
public:
	MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title)
	{
		wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);

		m_button = new wxButton(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0);
		m_button->Bind(wxEVT_MOVE, [this](wxMoveEvent& event) {
			m_textCtrl->AppendText("Move");
			event.Skip();
			});

		topSizer->Add(m_button, 0, wxALL, 5);

		m_button2 = new wxButton(this, wxID_ANY, wxT("Click"), wxDefaultPosition, wxDefaultSize, 0);
		m_button2->Bind(wxEVT_COMMAND_BUTTON_CLICKED,
			[&](wxCommandEvent& event)
			{
				m_button->Move(50, 0);
			});

		topSizer->Add(m_button2, 0, wxALL, 5);
		m_textCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
		topSizer->Add(m_textCtrl, 0, wxALL, 5);

		this->SetSizer(topSizer);
		this->Layout();
		this->Centre(wxBOTH);
	}
private:
	wxButton* m_button;
	wxButton* m_button2;
	wxTextCtrl* m_textCtrl;
};

class MyApp : public wxApp
{
public:
	virtual bool OnInit()
	{
		if (!wxApp::OnInit())
			return false;
		MyFrame* frame = new MyFrame("wxWidgets application");
		frame->Show(true);
		return true;
	}
};

wxIMPLEMENT_APP(MyApp);
I got second "Move" text after click on Button with label.

Re: wxMoveEvent and wxButton

Posted: Mon Sep 02, 2019 4:03 pm
by doublemax
I think the documentation is just wrong/outdated. When searching the search code, you can see that the event is also generated under GTK and OSX.

Re: wxMoveEvent and wxButton

Posted: Mon Sep 02, 2019 5:48 pm
by Kvaz1r
Yeah, thanks, now I see. I am going to open ticket on trac.