lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 2922db9 44/46: Disallow single cell operation


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 2922db9 44/46: Disallow single cell operations when non-current row is selected
Date: Wed, 22 Jul 2020 11:05:17 -0400 (EDT)

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

    Disallow single cell operations when non-current row is selected
    
    When a row different from the current one (as indicated by the grid
    cursor) is selected, it can be unclear whether the various operations
    applying to a single cell, such as "Edit cell" or "Run cell", apply to
    the selected row or the current one.
    
    Resolve this ambiguity by simply disallowing such operations in this
    situation.
---
 census_view.cpp | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/census_view.cpp b/census_view.cpp
index 0910b75..7f4b044 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -2469,13 +2469,20 @@ void 
CensusGridView::UponUpdateSingleSelection(wxUpdateUIEvent& e)
 {
     // We consider that in absence of any selected rows, the current row is the
     // selected/active one, so what we actually check for here is that we do
-    // not have more than a single row selected.
-    auto const sel_blocks = grid_window_->GetSelectedRowBlocks();
-    bool const is_single_sel
-        =  sel_blocks.empty()
-        || (sel_blocks.size() == 1
-            && sel_blocks[0].GetTopRow() == sel_blocks[0].GetBottomRow())
-        ;
+    // not have any rows other than, possibly, the current one, selected.
+    bool is_single_sel = true;
+    for(auto const& sel_block : grid_window_->GetSelectedRowBlocks())
+        {
+            auto const cursor_row = grid_window_->GetGridCursorRow();
+            if
+                (  sel_block.GetTopRow()    != cursor_row
+                || sel_block.GetBottomRow() != cursor_row
+                )
+                {
+                is_single_sel = false;
+                break;
+                }
+        }
 
     e.Enable(is_single_sel);
 }



reply via email to

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