lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master ece93a0 17/46: Make check for Alt-Enter more


From: Greg Chicares
Subject: [lmi-commits] [lmi] master ece93a0 17/46: Make check for Alt-Enter more obvious in the code
Date: Wed, 22 Jul 2020 11:05:11 -0400 (EDT)

branch: master
commit ece93a041e024fa61db6e7680ff97975d7c77ef4
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Vadim Zeitlin <vadim@tt-solutions.com>

    Make check for Alt-Enter more obvious in the code
    
    No real changes, just replace a switch+if with a single if: while it
    uses a more complication condition, the code control flow is now more
    explicit and clear.
---
 census_view.cpp | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/census_view.cpp b/census_view.cpp
index 8f29629..92eeb6d 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -1062,27 +1062,23 @@ void DatumSequenceEditor::Create
         evtHandler = m_control;
         }
 
+    // Use a special handler to open the editor window when Alt-Enter is
+    // pressed instead of just closing the editor, as would be done by default.
     evtHandler->Bind
         (wxEVT_KEY_DOWN
         ,[entry](wxKeyEvent& event)
         {
-            switch(event.GetKeyCode())
+            auto const code = event.GetKeyCode();
+            if
+                (  (code == WXK_RETURN || code == WXK_NUMPAD_ENTER)
+                && wxGetKeyState(WXK_ALT)
+                )
                 {
-                case WXK_RETURN:
-                case WXK_NUMPAD_ENTER:
-                    if(!wxGetKeyState(WXK_ALT))
-                        {
-                        event.Skip();
-                        return;
-                        }
-
-                    // Open the editor window when Alt-Enter is pressed 
instead of
-                    // just closing the editor, as would be done by default.
-                    entry->open_editor();
-                    break;
-                default:
-                    event.Skip();
-                    break;
+                entry->open_editor();
+                }
+            else
+                {
+                event.Skip();
                 }
         });
 }



reply via email to

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