Revision: 9157
Author: [email protected]
Date: Wed Oct 27 07:59:52 2010
Log: DefaultSuggestionDisplay: Allowing custom position object

Review at http://gwt-code-reviews.appspot.com/1038801

Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=9157

Modified:
 /trunk/user/src/com/google/gwt/user/client/ui/SuggestBox.java

=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/SuggestBox.java Thu Sep 23 14:30:55 2010 +++ /trunk/user/src/com/google/gwt/user/client/ui/SuggestBox.java Wed Oct 27 07:59:52 2010
@@ -306,6 +306,12 @@
      * matches" message.
      */
     private boolean hideWhenEmpty = true;
+
+    /**
+     * Object to position the suggestion display next to, instead of the
+     * associated suggest box.
+     */
+    private UIObject positionRelativeTo;

     /**
      * Construct a new {...@link DefaultSuggestionDisplay}.
@@ -358,6 +364,16 @@
       suggestionPopup.setStyleName(style);
     }

+    /**
+ * Sets the UI object where the suggestion display should appear next to.
+     *
+ * @param uiObject the uiObject used for positioning, or null to position
+     *     relative to the suggest box
+     */
+    public void setPositionRelativeTo(UIObject uiObject) {
+      positionRelativeTo = uiObject;
+    }
+
     /**
* Set whether or not the suggestion list should be hidden when there are
      * no suggestions to display. Defaults to true.
@@ -505,7 +521,8 @@
       }

       // Show the popup under the TextBox.
-      suggestionPopup.showRelativeTo(suggestBox);
+      suggestionPopup.showRelativeTo(positionRelativeTo != null
+          ? positionRelativeTo : suggestBox);
     }

     @Override

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to