Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16834/src/gui
Modified Files:
wxTemplateDialog.cpp
Log Message:
really fixed initial focus problem in the template choice dialog (Ok button
must not be initially disabled)
Index: wxTemplateDialog.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxTemplateDialog.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -b -u -2 -r1.40 -r1.41
--- wxTemplateDialog.cpp 30 Jun 2005 13:19:01 -0000 1.40
+++ wxTemplateDialog.cpp 30 Jun 2005 14:22:33 -0000 1.41
@@ -187,5 +187,5 @@
// controls
- wxListBox *m_listbox;
+ wxPListBox *m_listbox;
wxButton *m_btnAdd,
*m_btnDelete;
@@ -206,7 +206,13 @@
protected:
// event handlers
- void OnUpdateUIOk(wxUpdateUIEvent& event);
+ void OnListboxSelection(wxCommandEvent& event);
void OnListboxDoubleClick(wxCommandEvent& event);
+ void DoUpdateUI()
+ {
+ // only enable the ok button if there is a valid selection
+ FindWindow(wxID_OK)->Enable(m_listbox->GetSelection() != -1);
+ }
+
virtual wxString GetTemplateTitle(MessageTemplateKind kind) const;
@@ -273,7 +279,6 @@
BEGIN_EVENT_TABLE(wxChooseTemplateDialog, wxTemplatesDialogBase)
+ EVT_LISTBOX(-1, wxChooseTemplateDialog::OnListboxSelection)
EVT_LISTBOX_DCLICK(-1, wxChooseTemplateDialog::OnListboxDoubleClick)
-
- EVT_UPDATE_UI(wxID_OK, wxChooseTemplateDialog::OnUpdateUIOk)
END_EVENT_TABLE()
@@ -644,5 +649,5 @@
{
wxString value;
- if ( !!m_name )
+ if ( !m_name.empty() )
{
value = GetMessageTemplate(m_kind, m_name);
@@ -654,5 +659,5 @@
void wxTemplatesDialogBase::SaveChanges()
{
- wxASSERT_MSG( !!m_name, _T("shouldn't try to save") );
+ wxASSERT_MSG( !m_name.empty(), _T("shouldn't try to save") );
SetMessageTemplate(m_name, m_textctrl->GetValue(), m_kind, NULL);
@@ -766,10 +771,17 @@
m_textctrl->SetConstraints(c);
- FindWindow(wxID_OK)->SetFocus();
+ // we need to restore selection right now, without waiting for the listbox
+ // to do it itself later, as otherwise we'd disable the "Ok" button in
+ // DoUpdateUI() initially and this means that the focus wouldn't be given to
+ // it (focus never goes to disabled controls)
+ m_listbox->RestoreSelection();
+ DoUpdateUI();
}
-void wxChooseTemplateDialog::OnUpdateUIOk(wxUpdateUIEvent& event)
+void wxChooseTemplateDialog::OnListboxSelection(wxCommandEvent& event)
{
- event.Enable( m_listbox->GetSelection() != -1 );
+ DoUpdateUI();
+
+ event.Skip();
}
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates