Events logging and playback Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
vsp
Knows some wx things
Knows some wx things
Posts: 35
Joined: Mon Feb 21, 2005 12:52 pm

Events logging and playback

Post by vsp » Tue Feb 03, 2009 11:24 am

Code: Select all



EVT_COMMAND_RANGE ( 10001 , 10020, wxEVT_COMMAND_BUTTON_CLICKED , MainFrame::OnClick )

wxPanel* MainFrame::BuildEventPanel()
{
    wxPanel *panel = new wxPanel ( this , wxID_ANY );

	wxBoxSizer *buttonSizer1 = new wxBoxSizer ( wxHORIZONTAL );
	wxButton *bn1 = new wxButton ( panel , 10001 , wxT("Button1") );
	wxButton *bn2 = new wxButton ( panel , 10002 , wxT("Button2") );
	wxButton *bn3 = new wxButton ( panel , 10003 , wxT("Button3") );
	wxButton *bn4 = new wxButton ( panel , 10004 , wxT("Button4") );
	wxButton *bn5 = new wxButton ( panel , 10005 , wxT("Button5") );

	buttonSizer1->Add ( bn1 , 0 , wxALL , 5 );
	buttonSizer1->Add ( bn2 , 0 , wxALL , 5 );
	buttonSizer1->Add ( bn3 , 0 , wxALL , 5 );
	buttonSizer1->Add ( bn4 , 0 , wxALL , 5 );
	buttonSizer1->Add ( bn5 , 0 , wxALL , 5 );

	wxBoxSizer *buttonSizer2 = new wxBoxSizer ( wxHORIZONTAL );
	wxButton *bn6 = new wxButton ( panel , 10006 , wxT("Button6") );
	wxButton *bn7 = new wxButton ( panel , 10007 , wxT("Button7") );
	wxButton *bn8 = new wxButton ( panel , 10008 , wxT("Button8") );
	wxButton *bn9 = new wxButton ( panel , 10009 , wxT("Button9") );
	wxButton *bn10 = new wxButton ( panel , 10010 , wxT("Button10") );

	buttonSizer2->Add ( bn6 , 0 , wxALL , 5 );
	buttonSizer2->Add ( bn7 , 0 , wxALL , 5 );
	buttonSizer2->Add ( bn8 , 0 , wxALL , 5 );
	buttonSizer2->Add ( bn9 , 0 , wxALL , 5 );
	buttonSizer2->Add ( bn10 , 0 , wxALL , 5 );

	wxBoxSizer *buttonSizer = new wxBoxSizer ( wxVERTICAL );
	buttonSizer->Add ( buttonSizer1 , 0 , wxALL , 10 );
	buttonSizer->Add ( buttonSizer2 , 0 , wxALL , 10 );

	panel->SetAutoLayout(true);
	panel->SetSizer(buttonSizer);
	buttonSizer->Fit(panel);
	buttonSizer->SetSizeHints(panel);

	return panel;
}

void MainFrame::OnClick(wxCommandEvent& event )
{
	wxMessageBox ( wxString::Format( wxT("Button(%d) clicked") , event.GetId()));
	
        event.Skip();
}

void MainFrame::OnPlayMacro(wxCommandEvent& WXUNUSED(event))
{

	wxCommandEvent event;
	event.SetId(10012);
	event.SetEventObject( this );
	GetEventHandler()->ProcessEvent( event );
		
}

The above is the code snippet for event logging and palyback.

I am trying to execute OnPlayMacro function inorder to execute the OnClick() event programatically. Of course I have hard coded the button id, but it can be any be any valid button id with in the definied range.

When I execute the OnPlayMacro() this is not processing the event. Any help on how to fix this issue will be greatly appreciated.

Thanks.

VSP.

User avatar
doublemax
Moderator
Moderator
Posts: 14305
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Tue Feb 03, 2009 11:41 am

there is at least a

Code: Select all

event.SetEventType(wxEVT_COMMAND_BUTTON_CLICKED);
missing. But i'm not sure if this will work even after adding this.
Use the source, Luke!

venkat_sp
Earned a small fee
Earned a small fee
Posts: 16
Joined: Mon Sep 08, 2008 2:20 pm

Post by venkat_sp » Thu Feb 05, 2009 8:46 am

Thanks. Its working

Post Reply