[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] (no subject)
From: |
Greg Chicares |
Subject: |
[lmi-commits] (no subject) |
Date: |
Sat, 28 May 2016 01:28:06 +0000 (UTC) |
branch: master
commit 7040041a20aa098cfe64c8372594635806ff1cad
Author: Vadim Zeitlin <address@hidden>
Date: Thu Nov 19 01:40:33 2015 +0100
Open editor from keyboard in InputSequenceEntry
Handle Alt-Enter in InputSequenceTextCtrl as a shortcut for opening
the editor dialog to allow doing it from keyboard even when
InputSequenceTextCtrl is embedded in wxDataViewCtrl (as it happens
when it's used in CensusView) and TAB-bing to the button is impossible
as TAB presses are intercepted by wxDataViewCtrl to pass to the next
cell.
Additionally, using Alt-Enter is simpler than using Tab,Enter even
when the control is used standalone.
---
input_sequence_entry.cpp | 52 +++++++++++++++++++++++++++++++++++++++-------
input_sequence_entry.hpp | 3 +++
2 files changed, 47 insertions(+), 8 deletions(-)
diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 1f0c2e5..1ad5280 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -1184,7 +1184,14 @@ class InputSequenceTextCtrl
};
InputSequenceTextCtrl::InputSequenceTextCtrl(wxWindow* parent, wxWindowID id)
- :wxTextCtrl(parent, id)
+ :wxTextCtrl
+ (parent
+ ,id
+ ,wxString()
+ ,wxDefaultPosition
+ ,wxDefaultSize
+ ,wxTE_PROCESS_ENTER
+ )
{
::Connect
(this
@@ -1265,6 +1272,12 @@ bool InputSequenceEntry::Create
,NULL
,this
);
+ text_->Connect
+ (wxEVT_TEXT_ENTER
+ ,wxCommandEventHandler(InputSequenceEntry::UponEnter)
+ ,NULL
+ ,this
+ );
button_->Connect
(wxEVT_KILL_FOCUS
@@ -1342,8 +1355,38 @@ void
InputSequenceEntry::UponChildKillFocus(wxFocusEvent& event)
event.Skip();
}
+void InputSequenceEntry::UponEnter(wxCommandEvent& event)
+{
+ // Pressing Enter key without modifiers just accepts the changes, but we
+ // allow using Alt-Enter to open the input sequence editor dialog from
+ // keyboard.
+ if(!wxGetKeyState(WXK_ALT))
+ {
+ event.Skip();
+ return;
+ }
+
+ DoOpenEditor();
+
+ // Put focus back on the control itself as normal focus restoring logic
+ // doesn't work as we block some of the events in UponChildKillFocus().
+ text_->SetFocus();
+}
+
void InputSequenceEntry::UponOpenEditor(wxCommandEvent&)
{
+ DoOpenEditor();
+
+ // If this editor is used inside wxDataViewCtrl, don't keep focus after
+ // showing the dialog but give it to the parent to ensure that the editor
+ // is closed by it. Notice that there is no need to check if we actually
+ // are inside wxDataViewCtrl before doing it as otherwise our parent (e.g.
+ // a wxPanel) will just give focus back to us and nothing really happens.
+ GetParent()->SetFocus();
+}
+
+void InputSequenceEntry::DoOpenEditor()
+{
Input const& in = input();
// Center the window on the [...] button for best locality -- it will be
@@ -1394,13 +1437,6 @@ void InputSequenceEntry::UponOpenEditor(wxCommandEvent&)
editor.CentreOnParent();
editor.ShowModal();
-
- // If this editor is used inside wxDataViewCtrl, don't keep focus after
- // showing the dialog but give it to the parent to ensure that the editor
- // is closed by it. Notice that there is no need to check if we actually
- // are inside wxDataViewCtrl before doing it as otherwise our parent (e.g.
- // a wxPanel) will just give focus back to us and nothing really happens.
- GetParent()->SetFocus();
}
IMPLEMENT_DYNAMIC_CLASS(InputSequenceEntryXmlHandler, wxXmlResourceHandler)
diff --git a/input_sequence_entry.hpp b/input_sequence_entry.hpp
index 5ad9b4a..e07e5f0 100644
--- a/input_sequence_entry.hpp
+++ b/input_sequence_entry.hpp
@@ -55,8 +55,11 @@ class InputSequenceEntry
private:
void UponChildKillFocus(wxFocusEvent&);
+ void UponEnter(wxCommandEvent&);
void UponOpenEditor(wxCommandEvent&);
+ void DoOpenEditor();
+
Input const* input_;
std::string field_name_;
- [lmi-commits] [lmi] master updated (0798ad3 -> b27a3af), Greg Chicares, 2016/05/27
- [lmi-commits] (no subject), Greg Chicares, 2016/05/27
- [lmi-commits] (no subject), Greg Chicares, 2016/05/27
- [lmi-commits] (no subject), Greg Chicares, 2016/05/27
- [lmi-commits] (no subject), Greg Chicares, 2016/05/27
- [lmi-commits] (no subject), Greg Chicares, 2016/05/27
- [lmi-commits] (no subject), Greg Chicares, 2016/05/27
- [lmi-commits] (no subject),
Greg Chicares <=
- [lmi-commits] (no subject), Greg Chicares, 2016/05/27