Add EnterPressed handled in UserDialog and Search (for description)

This commit is contained in:
Grégory Soutadé 2011-04-09 19:22:32 +02:00
parent 0e93b41bc7
commit 7533319ad4
4 changed files with 22 additions and 8 deletions

View File

@ -19,7 +19,7 @@
#include "AccountPanel.h" #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}; CHANGE_ACCOUNT_ID, CHANGE_CATEGORY_ID, RENAME_ID};
BEGIN_EVENT_TABLE(SearchPanel, wxPanel) 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(CHANGE_CATEGORY_ID, SearchPanel::OnButtonChangeCategory)
EVT_BUTTON(RENAME_ID, SearchPanel::OnButtonRename) EVT_BUTTON(RENAME_ID, SearchPanel::OnButtonRename)
EVT_SHOW(SearchPanel::OnShow) EVT_SHOW(SearchPanel::OnShow)
EVT_TEXT_ENTER(DESCRIPTION_ID, SearchPanel::OnEnter)
END_EVENT_TABLE() END_EVENT_TABLE()
#define UNESCAPE_CHARS(s) { \ #define UNESCAPE_CHARS(s) { \
@ -69,7 +70,8 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent
wxCAL_MONDAY_FIRST); 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(); wxSize size = _description->GetSize();
size.SetWidth(size.GetWidth()*2); size.SetWidth(size.GetWidth()*2);
_description->SetMinSize(size); _description->SetMinSize(size);
@ -261,6 +263,11 @@ void SearchPanel::Search()
_operations = _kiss->Search(description, dateFrom, dateTo, amountFrom, amountTo, categories,types, accounts); _operations = _kiss->Search(description, dateFrom, dateTo, amountFrom, amountTo, categories,types, accounts);
} }
void SearchPanel::OnEnter(wxCommandEvent& event)
{
OnButtonSearch(event);
}
void SearchPanel::OnButtonSearch(wxCommandEvent& event) void SearchPanel::OnButtonSearch(wxCommandEvent& event)
{ {
Search(); Search();

View File

@ -45,6 +45,7 @@ public:
wxString GetToolTip(); wxString GetToolTip();
void OnShow(wxShowEvent& event); void OnShow(wxShowEvent& event);
void OnEnter(wxCommandEvent& event);
void OnButtonSearch(wxCommandEvent& event); void OnButtonSearch(wxCommandEvent& event);
void OnOperationModified(wxGridEvent& event); void OnOperationModified(wxGridEvent& event);
void OnCalendarFromChange(wxCalendarEvent& event); void OnCalendarFromChange(wxCalendarEvent& event);

View File

@ -19,12 +19,13 @@
#include "UsersDialog.h" #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) BEGIN_EVENT_TABLE(UsersDialog, wxDialog)
EVT_BUTTON(BUTTON_OK_ID, UsersDialog::OnOK) EVT_BUTTON(BUTTON_OK_ID, UsersDialog::OnOK)
EVT_BUTTON(BUTTON_CANCEL_ID, UsersDialog::OnCancel) EVT_BUTTON(BUTTON_CANCEL_ID, UsersDialog::OnCancel)
EVT_BUTTON(BUTTON_NEW_USER_ID, UsersDialog::OnNewUser) EVT_BUTTON(BUTTON_NEW_USER_ID, UsersDialog::OnNewUser)
EVT_TEXT_ENTER(TEXT_PASSWORD_ID, UsersDialog::OnEnter)
END_EVENT_TABLE() END_EVENT_TABLE()
UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), -1, _("Users")), _kiss(kiss), _wxUI(parent) 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); wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
gridBagSizer = new wxGridBagSizer(4, 4); gridBagSizer = new wxGridBagSizer(4, 4);
label = new wxStaticText(this, -1, _("User ")); label = new wxStaticText(this, wxID_ANY, _("User "));
gridBagSizer->Add(label, wxGBPosition(0, 0)); gridBagSizer->Add(label, wxGBPosition(0, 0));
_users = new wxChoice(this, wxID_ANY); _users = new wxChoice(this, wxID_ANY);
gridBagSizer->Add(_users, wxGBPosition(0, 1)); 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)); 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)); gridBagSizer->Add(_password, wxGBPosition(1, 1));
_password->SetWindowStyle(wxTE_PASSWORD);
wxButton* ok = new wxButton(this, BUTTON_OK_ID, _("OK")); wxButton* ok = new wxButton(this, BUTTON_OK_ID, _("OK"));
wxButton* cancel = new wxButton(this, BUTTON_CANCEL_ID, _("Cancel")); wxButton* cancel = new wxButton(this, BUTTON_CANCEL_ID, _("Cancel"));
wxButton* newUser = new wxButton(this, BUTTON_NEW_USER_ID, _("New User")); wxButton* newUser = new wxButton(this, BUTTON_NEW_USER_ID, _("New User"));
@ -77,6 +77,11 @@ UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), -
ShowModal(); ShowModal();
} }
void UsersDialog::OnEnter(wxCommandEvent& event)
{
OnOK(event);
}
void UsersDialog::OnOK(wxCommandEvent& event) void UsersDialog::OnOK(wxCommandEvent& event)
{ {
// No users in database // No users in database

View File

@ -37,6 +37,7 @@ class UsersDialog : public wxDialog
public: public:
UsersDialog(KissCount* kiss, wxUI *parent); UsersDialog(KissCount* kiss, wxUI *parent);
void OnEnter(wxCommandEvent& event);
void OnOK(wxCommandEvent& event); void OnOK(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event); void OnCancel(wxCommandEvent& event);
void OnNewUser(wxCommandEvent& event); void OnNewUser(wxCommandEvent& event);