EVT_BUTTON(wxID_OK, PlayerSelectionDialog::ButtonCallback)
EVT_BUTTON(wxID_CANCEL, PlayerSelectionDialog::ButtonCallback)
EVT_LISTBOX(ID_LISTBOX, PlayerSelectionDialog::SelectCallback)
+ EVT_CLOSE(PlayerSelectionDialog::OnCloseWindow)
END_EVENT_TABLE()
PlayerSelectionDialog::PlayerSelectionDialog(
return m_player;
}
-bool PlayerSelectionDialog::OnClose()
+void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& event)
{
- // hide the dialog
- // NB don't return TRUE otherwise delete is called
m_player = "";
- Show(FALSE);
- return FALSE;
+ EndModal(wxID_CANCEL);
}
void PlayerSelectionDialog::SelectCallback(wxCommandEvent& event)
{
if (event.GetEventType() == wxEVT_COMMAND_LISTBOX_SELECTED)
{
-#ifdef __WXGTK__
- if (event.IsSelection())
-#endif
+// if (event.IsSelection())
m_textField->SetValue(event.GetString());
}
}
else
{
m_player = name;
- Show(FALSE);
+ EndModal(wxID_OK);
}
}
else
{
- wxMessageBox("Please enter your name", "Forty Thieves");
+ wxMessageBox("Please enter your name", "Forty Thieves");
}
}
else
{
m_player = "";
- Show(FALSE);
+ EndModal(wxID_CANCEL);
}
}