From 7533319ad491fe85ae7eef37a378412e76410668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 9 Apr 2011 19:22:32 +0200 Subject: [PATCH] Add EnterPressed handled in UserDialog and Search (for description) --- src/view/SearchPanel.cpp | 11 +++++++++-- src/view/SearchPanel.h | 1 + src/view/UsersDialog.cpp | 17 +++++++++++------ src/view/UsersDialog.h | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/view/SearchPanel.cpp b/src/view/SearchPanel.cpp index dde8494..5753b2f 100644 --- a/src/view/SearchPanel.cpp +++ b/src/view/SearchPanel.cpp @@ -19,7 +19,7 @@ #include "AccountPanel.h" -enum {SEARCH_ID, GRID_ID, CALENDAR_FROM_ID, CALENDAR_TO_ID, +enum {DESCRIPTION_ID=1, SEARCH_ID, GRID_ID, CALENDAR_FROM_ID, CALENDAR_TO_ID, CHANGE_ACCOUNT_ID, CHANGE_CATEGORY_ID, RENAME_ID}; BEGIN_EVENT_TABLE(SearchPanel, wxPanel) @@ -31,6 +31,7 @@ EVT_BUTTON(CHANGE_ACCOUNT_ID, SearchPanel::OnButtonChangeAccount) EVT_BUTTON(CHANGE_CATEGORY_ID, SearchPanel::OnButtonChangeCategory) EVT_BUTTON(RENAME_ID, SearchPanel::OnButtonRename) EVT_SHOW(SearchPanel::OnShow) +EVT_TEXT_ENTER(DESCRIPTION_ID, SearchPanel::OnEnter) END_EVENT_TABLE() #define UNESCAPE_CHARS(s) { \ @@ -69,7 +70,8 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent wxCAL_MONDAY_FIRST); - _description = new wxTextCtrl(this, wxID_ANY); + _description = new wxTextCtrl(this, DESCRIPTION_ID); + _description->SetWindowStyle(_description->GetWindowStyle() | wxTE_PROCESS_ENTER); wxSize size = _description->GetSize(); size.SetWidth(size.GetWidth()*2); _description->SetMinSize(size); @@ -261,6 +263,11 @@ void SearchPanel::Search() _operations = _kiss->Search(description, dateFrom, dateTo, amountFrom, amountTo, categories,types, accounts); } +void SearchPanel::OnEnter(wxCommandEvent& event) +{ + OnButtonSearch(event); +} + void SearchPanel::OnButtonSearch(wxCommandEvent& event) { Search(); diff --git a/src/view/SearchPanel.h b/src/view/SearchPanel.h index 07bff94..ce80751 100644 --- a/src/view/SearchPanel.h +++ b/src/view/SearchPanel.h @@ -45,6 +45,7 @@ public: wxString GetToolTip(); void OnShow(wxShowEvent& event); + void OnEnter(wxCommandEvent& event); void OnButtonSearch(wxCommandEvent& event); void OnOperationModified(wxGridEvent& event); void OnCalendarFromChange(wxCalendarEvent& event); diff --git a/src/view/UsersDialog.cpp b/src/view/UsersDialog.cpp index fcb846b..5a43486 100644 --- a/src/view/UsersDialog.cpp +++ b/src/view/UsersDialog.cpp @@ -19,12 +19,13 @@ #include "UsersDialog.h" -enum {BUTTON_OK_ID=1, BUTTON_CANCEL_ID, BUTTON_NEW_USER_ID}; +enum {TEXT_PASSWORD_ID=1, BUTTON_OK_ID, BUTTON_CANCEL_ID, BUTTON_NEW_USER_ID}; BEGIN_EVENT_TABLE(UsersDialog, wxDialog) EVT_BUTTON(BUTTON_OK_ID, UsersDialog::OnOK) EVT_BUTTON(BUTTON_CANCEL_ID, UsersDialog::OnCancel) EVT_BUTTON(BUTTON_NEW_USER_ID, UsersDialog::OnNewUser) +EVT_TEXT_ENTER(TEXT_PASSWORD_ID, UsersDialog::OnEnter) END_EVENT_TABLE() UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), -1, _("Users")), _kiss(kiss), _wxUI(parent) @@ -36,18 +37,17 @@ UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), - wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL); gridBagSizer = new wxGridBagSizer(4, 4); - label = new wxStaticText(this, -1, _("User ")); + label = new wxStaticText(this, wxID_ANY, _("User ")); gridBagSizer->Add(label, wxGBPosition(0, 0)); _users = new wxChoice(this, wxID_ANY); gridBagSizer->Add(_users, wxGBPosition(0, 1)); - label = new wxStaticText(this, -1, _("Password ")); + label = new wxStaticText(this, wxID_ANY, _("Password ")); gridBagSizer->Add(label, wxGBPosition(1, 0)); - _password = new wxTextCtrl(this, wxID_ANY); + _password = new wxTextCtrl(this, TEXT_PASSWORD_ID); + _password->SetWindowStyle(_password->GetWindowStyle() | wxTE_PASSWORD | wxTE_PROCESS_ENTER); gridBagSizer->Add(_password, wxGBPosition(1, 1)); - _password->SetWindowStyle(wxTE_PASSWORD); - wxButton* ok = new wxButton(this, BUTTON_OK_ID, _("OK")); wxButton* cancel = new wxButton(this, BUTTON_CANCEL_ID, _("Cancel")); wxButton* newUser = new wxButton(this, BUTTON_NEW_USER_ID, _("New User")); @@ -77,6 +77,11 @@ UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), - ShowModal(); } +void UsersDialog::OnEnter(wxCommandEvent& event) +{ + OnOK(event); +} + void UsersDialog::OnOK(wxCommandEvent& event) { // No users in database diff --git a/src/view/UsersDialog.h b/src/view/UsersDialog.h index 86ed765..d753628 100644 --- a/src/view/UsersDialog.h +++ b/src/view/UsersDialog.h @@ -37,6 +37,7 @@ class UsersDialog : public wxDialog public: UsersDialog(KissCount* kiss, wxUI *parent); + void OnEnter(wxCommandEvent& event); void OnOK(wxCommandEvent& event); void OnCancel(wxCommandEvent& event); void OnNewUser(wxCommandEvent& event);