#FEATURE by exept expecco_19_2_1
authorClaus Gittinger <cg@exept.de>
Sat, 18 Jan 2020 15:37:54 +0100
changeset 6209 76d74a400d6b
parent 6208 efd39055fb51
child 6210 607f13d508f8
#FEATURE by exept class: MenuPanel added: #grabMenuItemAtPoint: comment/format in: #itemAtPoint: changed: #processShortcut:
MenuPanel.st
--- a/MenuPanel.st	Thu Jan 16 17:23:07 2020 +0100
+++ b/MenuPanel.st	Sat Jan 18 15:37:54 2020 +0100
@@ -5266,10 +5266,6 @@
         ^ false.
     ].
 
-    rawKey := aKeyEvent rawKey.
-    item := nil.
-    menu := self detectGrabMenu. "/ first lookup the current grabMenu before starting in the topMenu
-
     "/ special for Cmd-only event (i.e. ALT-only)
     aKeyEvent isKeyReleaseEvent ifTrue:[
         selection isNil ifTrue:[
@@ -5284,15 +5280,18 @@
         ^ true
     ].
 
+    rawKey := aKeyEvent rawKey.
+    item := nil.
+    menu := self detectGrabMenu. "/ first lookup the current grabMenu before starting in the topMenu
+
     "sr: bugfix:
      the submenu can be cached,
      so if we don't care about resources here (which seams like a performance optimization),
      we have non translated sub menus (when using them later for viewing).
      Problem expecco Menu 'View' was somethimes untranslated and somethimes not.
      Dependent if this code was called before the user did open (instantiate) the menu via the application.
-     May also the shortcuts itself could vary when translated 'Open &File' -> 'Datei &öffnen' ????"
-    Menu::NeedResourcesQuery answer:true do:[
-"/    Menu::NeedResourcesQuery answer:false do:[
+     Also the shortcuts itself could vary when translated 'Open &File' -> 'Datei &öffnen' ????"
+    Menu::NeedResourcesQuery answer:true "sr - was: false" do:[
         [true] whileTrue:[
             list := menu
                         selectItemIndicesFor:[:el|
@@ -6095,6 +6094,18 @@
     ^ dstMenu ? firstMenu
 !
 
+grabMenuItemAtPoint:aPoint
+    "returns the item in the active menu at aPoint or nil if none detected.
+     aPoint is relative to myself and might be outside, if I have gabbed the mouse
+     and a submenu is currently active)"
+
+    |menu translatedPoint|
+
+    menu := self detectGrabMenu.
+    translatedPoint := menu translateGrabPoint:aPoint.
+    ^ menu itemAtPoint:translatedPoint
+!
+
 itemAt:stringOrNumberOrPoint
     "returns item assigned to an index, nameKey, textLabel or value if symbol.
      If no item match nil is returned."
@@ -6110,7 +6121,10 @@
 !
 
 itemAtPoint:aPoint
-    "returns the item at aPoint or nil if none detected"
+    "returns the item at aPoint or nil if none detected.
+     aPoint is within myself 
+     (which might be outside, if I have gabbed the mouse
+      and a submenu is currently active)"
 
     |x y|