class: Tools::ViewTreeInspectorApplication
authorClaus Gittinger <cg@exept.de>
Thu, 05 Jun 2014 17:21:18 +0200
changeset 3124 1973e28a2c75
parent 3123 5bdc0a26498c
child 3125 9d5624af77ab
class: Tools::ViewTreeInspectorApplication class definition added: #doCatchEvents #isCatchingEventsChannel #isNotCatchingEventsChannel #openInPickModeAndRelease changed:8 methods lock/unlock toolbar item behavior; provide chance to come up unlocked.
Tools__ViewTreeApplication.st
--- a/Tools__ViewTreeApplication.st	Thu May 29 11:50:18 2014 +0200
+++ b/Tools__ViewTreeApplication.st	Thu Jun 05 17:21:18 2014 +0200
@@ -16,7 +16,8 @@
 ToolApplicationModel subclass:#ViewTreeInspectorApplication
 	instanceVariableNames:'model treeView hasSingleSelectionHolder clickedItem clickedPoint
 		motionAction process followFocusChannel showNamesHolder
-		inspectorView inspectorModeIndexHolder path'
+		inspectorView inspectorModeIndexHolder path
+		isCatchingEventsChannel'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-Smalltalk'
@@ -169,10 +170,10 @@
     ^super flyByHelpSpec addPairsFrom:#(
 
 #doUncatchEvents
-'Release Picked View and Uncatch Events (Currently Locked)'  
+'Release picked view and uncatch events\(currently locked for widget selection)'  
 
 #doCatchEvents
-'Release Picked View and Uncatch Events (Currently Unlocked)'  
+'Lock view and catch events for widget selection\(currently unlocked)'  
 
 )
 ! !
@@ -831,12 +832,23 @@
           )
          (MenuItem
             enabled: hasTargetWidgetChannel
+            isVisible: isNotCatchingEventsChannel
+            label: 'Catch Events of Picked View'
+            activeHelpKey: doCatchEvents
+            itemValue: doCatchEvents
+            nameKey: doCatchEvents
+            isButton: true
+            labelImage: (ResourceRetriever nil releaseViewIcon)
+          )
+         (MenuItem
+            enabled: hasTargetWidgetChannel
+            isVisible: isCatchingEventsChannel
             label: 'Release Picked View and Uncatch Events'
             activeHelpKey: doUncatchEvents
             itemValue: doUncatchEvents
             nameKey: doUncatchEvents
             isButton: true
-            labelImage: (ResourceRetriever nil releaseViewIcon)
+            labelImage: (ResourceRetriever nil lockViewIcon)
           )
          (MenuItem
             label: '-'
@@ -875,6 +887,17 @@
     app := self new.
     app open.
     app doPickView.
+    ^ app
+!
+
+openInPickModeAndRelease
+    "release the pick-lock after picking"
+
+    |app|
+
+    app := self openInPickMode.
+    app doUncatchEvents.
+    ^ app
 !
 
 openOn:aView
@@ -886,6 +909,7 @@
     app := self new.
     app open.
     app showWindow:aView.
+    ^ app
 ! !
 
 !ViewTreeInspectorApplication methodsFor:'actions'!
@@ -965,6 +989,14 @@
     "Created: / 30-07-2013 / 09:42:16 / cg"
 !
 
+isCatchingEventsChannel
+    ^ isCatchingEventsChannel
+!
+
+isNotCatchingEventsChannel
+    ^ BlockValue forLogicalNot:self isCatchingEventsChannel
+!
+
 listOfItems
     "returns the hierarchical list of items"
 
@@ -1317,6 +1349,7 @@
 
     hasSingleSelectionHolder := false asValue.
     followFocusChannel       := false asValue.
+    isCatchingEventsChannel  := false asValue.
     inspectorModeIndexHolder := 1 asValue.
     inspectorModeIndexHolder onChangeSend:#inspectorModeIndexHolderChanged to:self.
 
@@ -1916,6 +1949,15 @@
     "Modified: / 28-08-2013 / 23:57:42 / cg"
 !
 
+doCatchEvents
+    model catchEvents:true.
+    isCatchingEventsChannel value:true.
+"/    ((builder componentAt:'toolbarMenu') itemAt:#doUncatchEvents) 
+"/        enabled:true;
+"/        label:(self class releaseViewIcon);
+"/        activeHelpKey:#doUncatchEvents.
+!
+
 doDestroy
     "destroy the current selected view"
 
@@ -2026,7 +2068,9 @@
 doRedraw
     "redraw the app"
 
-    model rootView withAllSubViewsDo:[:v | v "redraw; "invalidate].
+    model rootView notNil ifTrue:[
+        model rootView withAllSubViewsDo:[:v | v "redraw; "invalidate].
+    ]
 !
 
 doSelectNextOfApplicationClass:aClass startingIn:anItem
@@ -2082,11 +2126,14 @@
 !
 
 doUncatchEvents
+    "release the inspected window (no longer catch its events)"
+
     model catchEvents:false.
-    ((builder componentAt:'toolbarMenu') itemAt:#doUncatchEvents) 
-        label:(self class releaseViewIcon);
-        enabled:false;
-        activeHelpKey:#doCatchEvents.
+    isCatchingEventsChannel value:false.
+"/    ((builder componentAt:'toolbarMenu') itemAt:#doUncatchEvents) 
+"/        label:(self class releaseViewIcon);
+"/        enabled:false;
+"/        activeHelpKey:#doCatchEvents.
     self doRedraw
 !
 
@@ -2108,11 +2155,7 @@
 
     topWindow := aView topView.
 
-    model catchEvents:true.
-    ((builder componentAt:'toolbarMenu') itemAt:#doUncatchEvents) 
-        enabled:true;
-        label:(self class releaseViewIcon);
-        activeHelpKey:#doUncatchEvents.
+    self doCatchEvents.
     self setRootItem:(ViewTreeItem buildViewsFrom:topWindow).
     self selectView:aView.
 ! !