#BUGFIX by cg
authorClaus Gittinger <cg@exept.de>
Fri, 29 Mar 2019 14:14:26 +0100
changeset 4251 159146f89764
parent 4250 e40bbfdb6fdb
child 4252 ebdd626ee83b
#BUGFIX by cg class: ActiveHelp FIX: if embedded widgets are inside a container (DSVColumnView, again) added: #basicHelpTextFor:at: comment/format in: #buttonMotion:x:y:view: #handleMouseIn:x:y: #initiateHelp #initiateHelpFor: #interestedIn: #keyPress:x:y:view: #keyRelease:x:y:view: #processEvent: changed: #helpTextFor:at: #initiateHelpFor:at: #initiateHelpFor:at:now: #pointerEnter:x:y:view: #pointerLeave:view:
ActiveHelp.st
--- a/ActiveHelp.st	Thu Mar 28 09:19:31 2019 +0100
+++ b/ActiveHelp.st	Fri Mar 29 14:14:26 2019 +0100
@@ -440,12 +440,19 @@
 
     |realViewUnderCursor realP|
 
+    "/ DebuggingEvents := true
+    "/ DebuggingEvents := false
+    DebuggingEvents == true ifTrue:[
+        ('%1: Motion view:%2' 
+                bindWith:self class name 
+                with:aView) infoPrintCR.
+    ].
     "/ Debugging := true
     buttonAndModifierState == 0 ifTrue:[
 "/        realViewUnderCursor := aView device viewFromPoint:(aView pointerPosition).
 "/        realP := aView device translatePoint:(x@y) fromView:aView toView:realViewUnderCursor.
 "/        self handleMouseIn:realViewUnderCursor x:realP x y:realP y.
-        Debugging ifTrue:[('motion %2@%3 in %1' bindWith:aView with:x with:y) infoPrintCR].
+        Debugging ifTrue:[('%1: motion %3@%4 in %5' bindWith:self class name with:aView with:x with:y) infoPrintCR].
         self handleMouseIn:aView x:x y:y.
     ].
     ^ false
@@ -459,9 +466,9 @@
 
     "/ Debugging := true. 
     "/ Debugging := false. 
-    Debugging ifTrue:['mouse in' infoPrintCR].
+    Debugging ifTrue:[('%1: mouse in' bindWith:self class name) infoPrintCR].
     (self interestedIn:aView) ifFalse:[
-        Debugging ifTrue:[Timestamp now infoPrint. ' - not interested 0' infoPrintCR].
+        Debugging ifTrue:[('%1: not interested in view (%2)' bindWith:self class name with:Timestamp now) infoPrintCR].
         ^ self
     ].
 
@@ -488,7 +495,7 @@
         (self targetViewInitiatesHelpViaSensor
         and:[ (sensor := aView sensor) notNil ])
         ifTrue:[
-            Debugging ifTrue:['target shows help' infoPrintCR].
+            Debugging ifTrue:[('%1 target shows help' bindWith:self class name) infoPrintCR].
             sensor flushEventsFor:self withType:#initiateHelpFor:at:.
             sensor 
                 pushUserEvent:#initiateHelpFor:at: for:self 
@@ -505,7 +512,9 @@
 keyPress:key x:x y:y view:view
     "unconditionally hide the help view"
 
-    Debugging ifTrue:['key press: ' infoPrint. key infoPrintCR].
+    Debugging ifTrue:[
+        ('%1: key press: %2' bindWith:self class name with:key) infoPrintCR
+    ].
     key == #Help ifTrue:[
         self initiateHelpFor:view at:(x @ y).
         ^ true.
@@ -520,8 +529,10 @@
 keyRelease:key x:x y:y view:view
     "unconditionally hide the help view"
 
-    Debugging ifTrue:['key release: ' infoPrint. key infoPrintCR].
-    
+    Debugging ifTrue:[
+        ('%1: key release: %2' bindWith:self class name with:key) infoPrintCR
+    ].
+
     "/ key == #Help ifTrue:[
     "/ ].    
     self hideHelpIgnoringErrors.
@@ -534,6 +545,11 @@
 pointerEnter:state x:x y:y view:aView
     "handle pointer entering a view; prepare to show help"
 
+    "/ DebuggingEvents := true
+    "/ DebuggingEvents := false
+    DebuggingEvents == true ifTrue:[
+        ('%1: PointerEnter view:%2' bindWith:self class name with:aView) infoPrintCR.
+    ].
     state == 0 ifTrue:[
         self handleMouseIn:aView x:x y:y.
     ].    
@@ -545,6 +561,11 @@
 
     |sensor|
 
+    "/ DebuggingEvents := true
+    "/ DebuggingEvents := false
+    DebuggingEvents == true ifTrue:[
+        ('%1: PointerLeave view: %2' bindWith:self class name with:aView) infoPrintCR.
+    ].
     sensor := aView sensor.
     sensor notNil ifTrue:[
         sensor flushEventsFor:self withType:#initiateHelpFor:at:.
@@ -554,9 +575,13 @@
 !
 
 processEvent:ev
-    DebuggingEvents == true ifTrue:[
-        'event: ' infoPrint. ev class nameWithoutPrefix infoPrint.
-        ' view:' infoPrint. ev view infoPrintCR.
+    "/ DebuggingEvents := true
+    "/ DebuggingEvents := false
+    false "DebuggingEvents == true" ifTrue:[
+        ('%1: === event: %2 view:%3' 
+                bindWith:self class name 
+                with:ev class nameWithoutPrefix
+                with:ev view) infoPrintCR.
     ].
     (ev isPointerEnterLeaveEvent
     or:[ ev isButtonEvent
@@ -571,7 +596,7 @@
 
 !ActiveHelp methodsFor:'help texts'!
 
-helpTextFor:aView at:aDevicePointOrNil 
+basicHelpTextFor:aView at:aDevicePointOrNil 
     "retrieve helptext for aView as a string; 
      walk along the view's superView chain,
      asking models and views encountered while walking.
@@ -650,6 +675,40 @@
     "Modified: / 09-01-2018 / 16:46:37 / stefan"
 !
 
+helpTextFor:aView at:aDevicePointOrNil 
+    "retrieve helptext for aView as a string; 
+     walk along the view's superView chain,
+     asking models and views encountered while walking.
+     The first one who understands and returns a nonNil answer to the
+     #helpTextFor:at: or #helpTextFor: message ends this search and the
+     returned string is returned."
+
+    |text|
+
+    text := self basicHelpTextFor:aView at:aDevicePointOrNil.
+
+    "/ in case of embedded toggles, buttons, etc.
+    "/ walk along the container hierarchy...
+    text isNil ifTrue:[
+        |pntRel v|
+
+        pntRel := aDevicePointOrNil.
+        v := aView.
+        [text isNil and:[v superView notNil]] whileTrue:[
+            pntRel notNil ifTrue:[
+                pntRel := aView device translatePoint:pntRel fromView:v toView:(v superView).
+            ].
+            v := v superView.
+            text := self basicHelpTextFor:v at:pntRel
+        ].
+        v superView isNil ifTrue:[
+            Debugging ifTrue:['no superview provides helptext' infoPrintCR].
+            ^ nil
+        ].
+    ].
+    ^ text
+!
+
 helpTextFromModel:aModelOrTopView view:aView at:aPointOrNil 
     "helper: ask aModel for its helpText."
 
@@ -701,7 +760,7 @@
     "/ Debugging := true
     "/ Debugging := false
     aView isNil ifTrue:[
-        Debugging ifTrue:['nil view' infoPrintCR].
+        Debugging ifTrue:[('%1: nil view' bindWith:self class name)infoPrintCR].
         ^ false
     ].
 
@@ -714,8 +773,9 @@
 
     UserPreferences current onlyShowTooltipsForActiveWindow ifTrue:[
         Debugging ifTrue:[
-            ('TopView: %1 focus: %2 active: %3' 
-                bindWith:aViewsTopView
+            ('%1: TopView: %2 focus: %3 active: %4' 
+                bindWith:self class name
+                with:aViewsTopView
                 with:aViewsTopView graphicsDevice focusView
                 with:aViewsTopView isActive) infoPrintCR.
         ].
@@ -723,7 +783,7 @@
             Debugging ifTrue:[ 
                 |graphicsDevice focusVw|
                 
-                'topview inactive' infoPrintCR.
+                ('%1: topview inactive' bindWith:self class name) infoPrintCR.
                 graphicsDevice := aViewsTopView graphicsDevice.
                 graphicsDevice notNil ifTrue:[
                     focusVw := graphicsDevice focusView.
@@ -821,7 +881,7 @@
     screenPos := Display pointerPosition.
     Debugging == true ifTrue:[
         '----------------' infoPrintCR.
-        'pos: ' infoPrint. screenPos infoPrintCR.
+        ('%1: pos: %2' bindWith:self class name with:screenPos) infoPrintCR.
     ].    
     view := Display viewFromPoint:screenPos.
     Debugging == true ifTrue:[
@@ -846,7 +906,7 @@
     
     screenPos := Display pointerPosition.
     Debugging == true ifTrue:[
-        'pos: ' infoPrint. screenPos infoPrintCR.
+        ('%1: pos: %2' bindWith:self class name with:screenPos) infoPrintCR.
     ].    
     aView notNil ifTrue:[
         relativePos := Display translatePoint:screenPos fromView:nil toView:aView.
@@ -858,6 +918,9 @@
 
     "Created: / 27-02-2019 / 13:59:44 / Claus Gittinger"
     "Modified: / 27-02-2019 / 15:52:07 / Claus Gittinger"
+
+
+
 !
 
 initiateHelpFor:aView at:aPointOrNil
@@ -867,6 +930,10 @@
      re-negotiation of the displayed helpText 
      (for example in a menu, when the selection changes)"
 
+    Debugging == true ifTrue:[
+        ('%1: initiateHelpFor: %2' bindWith:self class name with:aView) infoPrintCR.
+    ].
+
     "/ ActiveHelp stop
     self class isActive ifFalse:[^ self].
 
@@ -890,14 +957,19 @@
     |text top app|
 
     Debugging == true ifTrue:[
-        'initiate help for: ' infoPrint. aView infoPrintCR.
-    ].    
+        ('%1: initiate help for: %2' bindWith:self class name with:aView) infoPrintCR.
+    ]. 
+
     (self interestedIn:aView) ifFalse:[
+        Debugging ifTrue:['not interested: ' infoPrintCR].
         ^ self
     ].
 
     text := self helpTextFor:aView at:aPointOrNil.
-    lastHelpText = text ifTrue:[
+
+    (lastHelpText = text and:[lastHelpWidget == aView]) ifTrue:[
+        Debugging ifTrue:['same text' infoPrintCR].
+        "/ (aView isKindOf:CheckToggle) ifTrue:[self halt].
         ^ self
     ].
 
@@ -906,6 +978,7 @@
     "/ nil-text is also passed down, to give it a chance
     "/ to clean its infoDisplay.
 
+    (aView isKindOf:CheckToggle) ifTrue:[self halt].
     top := aView topView.
     (app := aView application) notNil ifTrue:[
         (app showActiveHelp:text for:aView) ifTrue:[