#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 23 Apr 2019 20:06:49 +0200
changeset 6043 8d87fa82b05d
parent 6042 65ee63cf658e
child 6044 e7fd53f408b8
#FEATURE by cg class: DSVColumnView allow for the editor returned by the cell to be a dialogBox. Adjust needed in many places which check for the existance of an editView, to avoid opening the dialog twice (sigh - bad architecture) comment/format in: #selectRowAt:colAt:atPoint:openEditor: #setSelectColIndex:rowIndex:openEditor: changed: #buttonPress:x:y: #destroyEditView #forceAcceptInEditor #openEditorOnSelection
DSVColumnView.st
--- a/DSVColumnView.st	Tue Apr 23 20:05:22 2019 +0200
+++ b/DSVColumnView.st	Tue Apr 23 20:06:49 2019 +0200
@@ -37,7 +37,7 @@
 		selectionFrameColor selectionFrameColorNoFocus previousExtent
 		selectConditionBlock scrollRowWise autoScrollToColumn
 		cachedPreferredExtent sortListInPlace labelFgColor labelBgColor
-		updateListHolderWhenSorting ignoreReselect'
+		updateListHolderWhenSorting ignoreReselect didEditWithDialog'
 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
 		DefaultHilightForegroundColor DefaultHilightBackgroundColor
 		DefaultHilightFrameColor ButtonLightColor ButtonShadowColor
@@ -2736,7 +2736,8 @@
         ] ifFalse:[
             buttonReleaseAction :=
                 [
-                    self selectRowAt:rowNr colAt:colNr atPoint:clickPoint openEditor:true
+                    buttonReleaseAction := nil.
+                    self selectRowAt:rowNr colAt:colNr atPoint:clickPoint openEditor:true.
                 ].
 
             buttonMotionAction :=
@@ -2752,15 +2753,20 @@
     ((button == 2) and:[UserPreferences current selectOnRightClick]) ifFalse:[
         buttonReleaseAction :=
             [
+                buttonReleaseAction := nil.
                 self selectRowAt:rowNr colAt:colNr atPoint:clickPoint openEditor:true.
             ].
 
         "/ normally, we select on button release; however, any editor is shown immediately
         ((column := self columnDescriptorAt:colNr) notNil
-        and:[ (columnEditorType := column description editorType) notNil
-        and:[ columnEditorType ~~ #None ]]) ifTrue:[
+          and:[ (columnEditorType := column description editorType) notNil
+          and:[ columnEditorType ~~ #None ]]
+        ) ifTrue:[
             buttonReleaseAction value.
             buttonReleaseAction := nil.
+            (editView notNil and:[editView isDialogBox]) ifTrue:[
+                editView := nil.
+            ].    
             editView notNil ifTrue:[
                 ^ self.
             ]
@@ -2812,7 +2818,7 @@
     ].
 
     "Modified: / 12-07-2011 / 14:54:45 / cg"
-    "Modified (format): / 31-01-2019 / 23:39:56 / Claus Gittinger"
+    "Modified: / 23-04-2019 / 19:53:40 / Claus Gittinger"
 !
 
 buttonRelease:button x:x y:y
@@ -3647,10 +3653,13 @@
 
     editView notNil ifTrue:[ |winGroup focusView|
         self hasFocus ifTrue:[focusView := self].
-
-        editView withAllSubViewsDo:[:aView |
-            aView hasFocus ifTrue:[focusView := self].
-            aView delegate:nil
+        editView isDialogBox ifTrue:[
+            focusView := self
+        ] ifFalse:[    
+            editView withAllSubViewsDo:[:aView |
+                aView hasFocus ifTrue:[focusView := self].
+                aView delegate:nil
+            ].
         ].
         editView destroy.
         editView := nil.
@@ -3661,6 +3670,8 @@
             winGroup focusView:focusView.
         ]
     ].
+
+    "Modified: / 23-04-2019 / 19:13:41 / Claus Gittinger"
 !
 
 detectViewAt:aPoint in:aView
@@ -4455,13 +4466,17 @@
 
 forceAcceptInEditor
     editView notNil ifTrue:[
-        editView
-            allSubViewsDo:[:aSubView |
-                (aSubView respondsTo:#accept) ifTrue:[
-                    aSubView accept
-                ].
-            ]
+        editView isDialogBox ifFalse:[
+            editView
+                allSubViewsDo:[:aSubView |
+                    (aSubView respondsTo:#accept) ifTrue:[
+                        aSubView accept
+                    ].
+                ]
+        ]
     ]
+
+    "Modified: / 23-04-2019 / 19:17:04 / Claus Gittinger"
 !
 
 hasRowSelection
@@ -4642,6 +4657,17 @@
 
     editorAndModel := column editorForRowAt:rowIdx.
     editorAndModel isNil ifTrue:[^ self].
+    
+    editor := editorAndModel editor.
+    editor isDialogBox ifTrue:[
+        editor open.
+        editor accepted ifTrue:[
+            "/ editorAndModel acceptAction value:nil.
+        ].
+        editView := editor.
+        didEditWithDialog := true.
+        ^ self
+    ].    
 
     autoScrollToColumn == true ifTrue:[
         self scrollToRowAt:rowIdx colAt:colIdx.
@@ -4661,7 +4687,6 @@
     ].
     editView viewBackground:selectionBackgroundColor.
 
-    editor := editorAndModel editor.
     editView add:editor.
     editorAndModel editorNeedsCursorKeys ifTrue:[
         editorAndModel editorNeedsReturnKey ifTrue:[
@@ -4701,6 +4726,7 @@
     self processAllExposeEvents.
 
     "Modified: / 02-11-2010 / 22:04:01 / cg"
+    "Modified: / 23-04-2019 / 18:47:46 / Claus Gittinger"
 !
 
 processAllExposeEvents
@@ -4790,9 +4816,12 @@
     |view p shouldClick editorType|
 
     view := editView.
+    didEditWithDialog := false.
     self selectColIndex:colNr rowIndex:rowNr openEditor:openEditor.
     openEditor ifFalse:[ ^ self ].
 
+    didEditWithDialog ifTrue:[didEditWithDialog := false. ^ self].
+    
     editView isNil ifTrue:[
         "/ might be a reselection
         self openEditorOnSelection.
@@ -4865,7 +4894,7 @@
 
     "Modified: / 07-09-2011 / 16:08:45 / cg"
     "Modified: / 15-03-2017 / 21:09:54 / stefan"
-    "Modified: / 31-01-2019 / 23:38:26 / Claus Gittinger"
+    "Modified: / 23-04-2019 / 19:17:11 / Claus Gittinger"
 !
 
 selectRowFrom:start to:stop
@@ -5042,6 +5071,9 @@
     ].
 
     (rowNr = selectedRowIndex and:[ colNr == self selectedColIndex ]) ifTrue:[
+        (editView notNil and:[editView isDialogBox]) ifTrue:[
+            editView := nil
+        ].
         ^ self
     ].
 
@@ -5100,6 +5132,7 @@
     self processAllExposeEvents.
 
     "Modified: / 12-07-2011 / 14:22:42 / cg"
+    "Modified: / 23-04-2019 / 19:30:50 / Claus Gittinger"
 !
 
 updateColumnFromEditValueAndDestroyEditView