DefaultSuggestionDisplay: Allowing custom position object
Review at http://gwt-code-reviews.appspot.com/1038801
Review by: jlabanca@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9157 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/SuggestBox.java b/user/src/com/google/gwt/user/client/ui/SuggestBox.java
index a291aec..bbb054b 100644
--- a/user/src/com/google/gwt/user/client/ui/SuggestBox.java
+++ b/user/src/com/google/gwt/user/client/ui/SuggestBox.java
@@ -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}.
@@ -359,6 +365,16 @@
}
/**
+ * 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