added: #isOpenedAsSubmenu
authorClaus Gittinger <cg@exept.de>
Mon, 12 Oct 2009 15:01:45 +0200
changeset 3972 810842932c33
parent 3971 09f9900d0241
child 3973 6989efdd26ff
added: #isOpenedAsSubmenu changed: #buttonMotion:x:y: #buttonRelease:x:y: #hide bugFIX: D0101831 ctrl-click did not close the codeViews ctrl-menu
PopUpMenu.st
--- a/PopUpMenu.st	Mon Oct 12 14:49:03 2009 +0200
+++ b/PopUpMenu.st	Mon Oct 12 15:01:45 2009 +0200
@@ -1292,7 +1292,7 @@
 
     menuView hideSubmenu.
     super hide.
-    menuView superMenu notNil ifTrue:[
+    (self isOpenedAsSubmenu) ifTrue:[
         menuView superMenu regainControl
     ].
 
@@ -1321,7 +1321,7 @@
 !PopUpMenu methodsFor:'event handling'!
 
 buttonMotion:state x:x y:y
-    |p superMenu sensor|
+    |p sensor|
 
     "/ state == 0 ifTrue:[^ self].
 
@@ -1354,14 +1354,13 @@
     ].
 
     "outside of myself"
-    superMenu := menuView superMenu.
-    superMenu notNil ifTrue:[
+    (self isOpenedAsSubmenu) ifTrue:[
         p := device 
                 translatePoint:(x @ y)
                 fromView:self
                 toView:(menuView superMenu).
         p notNil ifTrue:[
-            superMenu buttonMotion:state x:p x y:p y
+            menuView superMenu buttonMotion:state x:p x y:p y
         ]
     ].
 
@@ -1415,7 +1414,7 @@
          "/   
          "/ released outside of mySelf
          "/
-        menuView superMenu notNil ifTrue:[
+        (self isOpenedAsSubmenu) ifTrue:[
             menuView superMenu hideSubmenu
         ] ifFalse:[
             self hide
@@ -1561,6 +1560,20 @@
 
 !PopUpMenu methodsFor:'private-accessing'!
 
+isOpenedAsSubmenu
+    "return true, if I have been opened as a submenu of some other
+     menu."
+
+    |superMenu|
+
+    superMenu := menuView superMenu.
+    "/ check for realized, because the CTRL/SHIFT menus of a textView
+    "/ are opened as top-menu AND have a non-nil supermenu.
+    "/ thus asking for supermenu being nonNil is NOT a sufficient indicator for
+    "/ being an open submenu !!
+    ^ superMenu notNil and:[superMenu realized]
+!
+
 menu:aMenuView
     "set the actual menu"
 
@@ -1624,9 +1637,9 @@
 !PopUpMenu class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.102 2009-10-12 10:10:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.103 2009-10-12 13:01:45 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.102 2009-10-12 10:10:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.103 2009-10-12 13:01:45 cg Exp $'
 ! !