You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/09/18 17:40:34 UTC

svn commit: r816675 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java

Author: tvolkert
Date: Fri Sep 18 15:40:34 2009
New Revision: 816675

URL: http://svn.apache.org/viewvc?rev=816675&view=rev
Log:
Changed menu popup handling in application context to set (and clear) the owner of the menu popup appropriately

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java?rev=816675&r1=816674&r2=816675&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java Fri Sep 18 15:40:34 2009
@@ -827,7 +827,8 @@
 
                                     if (component instanceof Container) {
                                         Container container = (Container)component;
-                                        component = container.getComponentAt(componentX, componentY);
+                                        component = container.getComponentAt(componentX,
+                                            componentY);
 
                                         if (component != null) {
                                             componentX -= component.getX();
@@ -845,14 +846,25 @@
                                     menuPopup.getWindowStateListeners().add(new WindowStateListener.Adapter() {
                                         @Override
                                         public void windowClosed(Window window, Display display) {
+                                            window.setOwner(null);
                                             menuPopup.getMenu().getSections().clear();
                                             menuPopup = null;
                                             window.getWindowStateListeners().remove(this);
                                         }
                                     });
 
-                                    Display display = mouseOwner.getDisplay();
-                                    menuPopup.open(display, mouseOwner.mapPointToAncestor(display, x, y));
+                                    Window window = null;
+                                    if (mouseOwner == display) {
+                                        window = (Window)display.getComponentAt(x, y);
+                                    } else {
+                                        window = mouseOwner.getWindow();
+                                    }
+
+                                    menuPopup.setOwner(window);
+
+                                    Display display = window.getDisplay();
+                                    menuPopup.open(display, mouseOwner.mapPointToAncestor(display,
+                                        x, y));
                                 }
                             }
 
@@ -871,8 +883,9 @@
                                     dragSource.endDrag(dragDescendant, null);
                                 } else {
                                     DropTarget dropTarget = dropDescendant.getDropTarget();
-                                    DropAction dropAction = dropTarget.drop(dropDescendant, dragManifest,
-                                        dragSource.getSupportedDropActions(), x, y, getUserDropAction(event));
+                                    DropAction dropAction = dropTarget.drop(dropDescendant,
+                                        dragManifest, dragSource.getSupportedDropActions(), x, y,
+                                        getUserDropAction(event));
                                     dragSource.endDrag(dragDescendant, dropAction);
                                 }