lmi-commits
[Top][All Lists]
Advanced

[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 88f6e9d4aa30b49509fc108dbb269e8718e4cd28
Author: Vadim Zeitlin <address@hidden>
Date:   Thu Nov 19 01:38:00 2015 +0100

    Handle focus loss in InputSequenceEntry itself
    
    Replace wxEVT_KILL_FOCUS handlers in InputSequenceTextCtrl and
    InputSequenceButton classes with a single handler for both of them in
    InputSequenceEntry.
    
    This slightly simplifies the code and also ensures that the more
    correct logic in the button event handler is used for the text control
    as well, so that things will work correctly if the editor can ever be
    shown while the text control has focus (which will eventually happen).
---
 input_sequence_entry.cpp |   63 +++++++++++++++++++---------------------------
 input_sequence_entry.hpp |    1 +
 2 files changed, 27 insertions(+), 37 deletions(-)

diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 25701f7..1f0c2e5 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -1180,7 +1180,6 @@ class InputSequenceTextCtrl
     InputSequenceTextCtrl(wxWindow* parent, wxWindowID id);
 
   private:
-    void UponKillFocus(wxFocusEvent& event);
     void UponChar(wxKeyEvent& event);
 };
 
@@ -1189,25 +1188,11 @@ InputSequenceTextCtrl::InputSequenceTextCtrl(wxWindow* 
parent, wxWindowID id)
 {
     ::Connect
             (this
-            ,wxEVT_KILL_FOCUS
-            ,&InputSequenceTextCtrl::UponKillFocus
-            );
-    ::Connect
-            (this
             ,wxEVT_CHAR
             ,&InputSequenceTextCtrl::UponChar
             );
 }
 
-void InputSequenceTextCtrl::UponKillFocus(wxFocusEvent& event)
-{
-    // Don't notify the parent (and thus wxDataViewCtrl) of focus change if
-    // it's within this InputSequenceEntry composite control.
-    if(0 == event.GetWindow() || event.GetWindow()->GetParent() != GetParent())
-        GetParent()->ProcessWindowEvent(event);
-    event.Skip();
-}
-
 void InputSequenceTextCtrl::UponChar(wxKeyEvent& event)
 {
     if(!GetParent()->ProcessWindowEvent(event))
@@ -1219,20 +1204,11 @@ class InputSequenceButton
 {
   public:
     InputSequenceButton(wxWindow* parent, wxWindowID id);
-
-  private:
-    void UponKillFocus(wxFocusEvent& event);
 };
 
 InputSequenceButton::InputSequenceButton(wxWindow* parent, wxWindowID id)
     :wxButton(parent, id, "...", wxDefaultPosition, wxDefaultSize, 
wxBU_EXACTFIT)
 {
-    ::Connect
-            (this
-            ,wxEVT_KILL_FOCUS
-            ,&InputSequenceButton::UponKillFocus
-            );
-
     SetToolTip("Open sequence editor");
 
     // Set vertical size to 1px - it's ridiculously small, but the sizers will 
make it as
@@ -1241,19 +1217,6 @@ InputSequenceButton::InputSequenceButton(wxWindow* 
parent, wxWindowID id)
     SetMinSize(wxSize(8 + GetTextExtent(GetLabel()).x, 1));
 }
 
-void InputSequenceButton::UponKillFocus(wxFocusEvent& event)
-{
-    // Don't notify the parent (and thus wxDataViewCtrl) of focus change if 
its within this
-    // InputSequenceEntry composite control or a InputSequenceEditor window 
opened from it.
-    if(0 == event.GetWindow() ||
-       (event.GetWindow()->GetParent() != GetParent() &&
-        wxGetTopLevelParent(event.GetWindow())->GetParent() != this))
-        {
-        GetParent()->ProcessWindowEvent(event);
-        }
-    event.Skip();
-}
-
 } // Unnamed namespace.
 
 InputSequenceEntry::InputSequenceEntry()
@@ -1296,6 +1259,19 @@ bool InputSequenceEntry::Create
 
     SetSizer(sizer);
 
+    text_->Connect
+        (wxEVT_KILL_FOCUS
+        ,wxFocusEventHandler(InputSequenceEntry::UponChildKillFocus)
+        ,NULL
+        ,this
+        );
+
+    button_->Connect
+        (wxEVT_KILL_FOCUS
+        ,wxFocusEventHandler(InputSequenceEntry::UponChildKillFocus)
+        ,NULL
+        ,this
+        );
     button_->Connect
         (wxEVT_COMMAND_BUTTON_CLICKED
         ,wxCommandEventHandler(InputSequenceEntry::UponOpenEditor)
@@ -1353,6 +1329,19 @@ std::string InputSequenceEntry::field_name() const
         }
 }
 
+void InputSequenceEntry::UponChildKillFocus(wxFocusEvent& event)
+{
+    // Don't notify the parent (and thus wxDataViewCtrl) of focus change if 
its within this
+    // InputSequenceEntry composite control or a InputSequenceEditor window 
opened from it.
+    if(0 == event.GetWindow() ||
+       (event.GetWindow()->GetParent() != GetParent() &&
+        wxGetTopLevelParent(event.GetWindow())->GetParent() != this))
+        {
+        GetParent()->ProcessWindowEvent(event);
+        }
+    event.Skip();
+}
+
 void InputSequenceEntry::UponOpenEditor(wxCommandEvent&)
 {
     Input const& in = input();
diff --git a/input_sequence_entry.hpp b/input_sequence_entry.hpp
index f752ef3..5ad9b4a 100644
--- a/input_sequence_entry.hpp
+++ b/input_sequence_entry.hpp
@@ -54,6 +54,7 @@ class InputSequenceEntry
     void set_popup_title(wxString const& title) {title_ = title;}
 
   private:
+    void UponChildKillFocus(wxFocusEvent&);
     void UponOpenEditor(wxCommandEvent&);
 
     Input const* input_;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]