How would I write an event that a control issues that expects a value to be returned?
I tried the following:
Code: Select all
class wxNoteCountEvent : public wxEvent
{
public:
wxNoteCountEvent( const wxNoteCountEvent &original );
wxNoteCountEvent( wxEventType commandType = wxEVT_NULL, int id = 0 );
virtual wxEvent *Clone() const { return new wxNoteCountEvent(*this); }
void SetCount(int value) { count = value; }
int GetCount() const { return count; }
private:
int count;
};
Code: Select all
int wxPianoRoll::GetNoteCount()
{
wxNoteCountEvent event( wxEVT_NOTE_COUNT, GetId() );
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
return event.GetCount();
}
Code: Select all
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
EVT_MENU(ID_QUIT, MainFrame::OnQuit)
EVT_MENU(ID_ABOUT, MainFrame::OnAbout)
EVT_NOTE_COUNT(ID_PIANOROLL, MainFrame::OnNoteCount)
END_EVENT_TABLE()
void MainFrame::OnNoteCount(wxNoteCountEvent &event)
{
event.SetCount(100);
}