UIObjectView.st
changeset 1230 23e5d0c133e8
parent 1222 bcb8b0ec295c
child 1342 75be821d97c3
--- a/UIObjectView.st	Wed Sep 22 18:59:10 1999 +0200
+++ b/UIObjectView.st	Wed Sep 22 20:11:46 1999 +0200
@@ -1344,6 +1344,21 @@
     ]
 !
 
+twoElementSelection
+    "checks whether exactly two elements are selected; 
+     in this case, return the selection collection.
+     otherwise return nil
+    "
+    |coll|
+
+    (coll := self selection) isCollection ifFalse:[
+        ^ nil "/ single
+    ].
+
+    coll size == 2 ifTrue:[ ^ coll].
+    ^ nil
+!
+
 unselect
     "clear selection
     "
@@ -1523,6 +1538,32 @@
 
 !
 
+exchangeLayouts
+    "exchange the layout of two elements 
+     (useful to change the order of radiobuttons or checkBoxes)
+    "
+    |objects l1 l2|
+
+    objects := self twoElementSelection.
+
+    objects notNil ifTrue:[
+        l1 := (objects at:1) geometryLayout copy.
+        l2 := (objects at:2) geometryLayout copy.
+        self transaction:#exchangeLayout dimensionDo:[:v|
+            v == (objects at:1) ifTrue:[
+                v geometryLayout:(l2 copy)
+            ] ifFalse:[
+                v geometryLayout:(l1 copy).
+            ]
+        ]    
+    ] ifFalse:[    
+        self warn:'exactly two elements must be selected'.
+    ]
+
+
+
+!
+
 pasteExtent
     "paste the copied extent to all objects in the selection
     "