fixed incorrect use of UpdateUI handlers; don't use duplicated Ctrl-S accel for two menu items; use the old label value by default when asking for the new one

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2007-02-08 15:04:24 +00:00
parent b33df83245
commit 26ef973fa2

View File

@ -88,8 +88,9 @@ public:
void Quit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
// Menu command update functions
void UpdateUI(wxUpdateUIEvent& event);
// UI update handlers
void OnCollapseUpdateUI(wxUpdateUIEvent& event);
void OnExpandUpdateUI(wxUpdateUIEvent& event);
private:
wxCollapsiblePane *m_collPane;
@ -149,7 +150,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(PANE_ABOUT, MyFrame::OnAbout)
EVT_MENU(PANE_QUIT, MyFrame::Quit)
EVT_UPDATE_UI(wxID_ANY, MyFrame::UpdateUI)
EVT_UPDATE_UI(PANE_COLLAPSE, MyFrame::OnCollapseUpdateUI)
EVT_UPDATE_UI(PANE_EXPAND, MyFrame::OnExpandUpdateUI)
END_EVENT_TABLE()
// My frame constructor
@ -167,7 +169,7 @@ MyFrame::MyFrame()
paneMenu->Append(PANE_COLLAPSE, _T("Collapse\tCtrl-C"));
paneMenu->Append(PANE_EXPAND, _T("Expand\tCtrl-E"));
paneMenu->AppendSeparator();
paneMenu->Append(PANE_SETLABEL, _T("Set label...\tCtrl-S"));
paneMenu->Append(PANE_SETLABEL, _T("Set label...\tCtrl-L"));
paneMenu->AppendSeparator();
paneMenu->Append(PANE_SHOWDLG, _T("Show dialog...\tCtrl-S"));
paneMenu->AppendSeparator();
@ -213,7 +215,12 @@ void MyFrame::OnExpand(wxCommandEvent& WXUNUSED(event) )
void MyFrame::OnSetLabel(wxCommandEvent& WXUNUSED(event) )
{
wxString text = wxGetTextFromUser(wxT("Input the new label"));
wxString text = wxGetTextFromUser
(
wxT("Enter new label"),
wxGetTextFromUserPromptStr,
m_collPane->GetLabel()
);
m_collPane->SetLabel(text);
}
@ -233,10 +240,14 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
wxAboutBox(info);
}
void MyFrame::UpdateUI(wxUpdateUIEvent& event)
void MyFrame::OnCollapseUpdateUI(wxUpdateUIEvent& event)
{
GetMenuBar()->Enable(PANE_COLLAPSE, !m_collPane->IsCollapsed());
GetMenuBar()->Enable(PANE_EXPAND, m_collPane->IsCollapsed());
event.Enable(!m_collPane->IsCollapsed());
}
void MyFrame::OnExpandUpdateUI(wxUpdateUIEvent& event)
{
event.Enable(m_collPane->IsCollapsed());
}