API Reference 0.3.24dart_web_toolkit_uiDialogBox

DialogBox class

A form of popup that has a caption area at the top and can be dragged by the user. Unlike a PopupPanel, calls to {@link #setWidth(String)} and {@link #setHeight(String)} will set the width and height of the dialog box itself, even if a widget has not been added as yet. <p> <img class='gallery' src='doc-files/DialogBox.png'/> </p> <h3>CSS Style Rules</h3>

  • .dwt-DialogBox { the outside of the dialog }
  • .dwt-DialogBox .Caption { the caption }
  • .dwt-DialogBox .dialogContent { the wrapper around the content }
  • .dwt-DialogBox .dialogTopLeft { the top left cell }
  • .dwt-DialogBox .dialogTopLeftInner { the inner element of the cell }
  • .dwt-DialogBox .dialogTopCenter { the top center cell, where the caption is located }
  • .dwt-DialogBox .dialogTopCenterInner { the inner element of the cell }
  • .dwt-DialogBox .dialogTopRight { the top right cell }
  • .dwt-DialogBox .dialogTopRightInner { the inner element of the cell }
  • .dwt-DialogBox .dialogMiddleLeft { the middle left cell }
  • .dwt-DialogBox .dialogMiddleLeftInner { the inner element of the cell }
  • .dwt-DialogBox .dialogMiddleCenter { the middle center cell, where the content is located }
  • .dwt-DialogBox .dialogMiddleCenterInner { the inner element of the cell }
  • .dwt-DialogBox .dialogMiddleRight { the middle right cell }
  • .dwt-DialogBox .dialogMiddleRightInner { the inner element of the cell }
  • .dwt-DialogBox .dialogBottomLeft { the bottom left cell }
  • .dwt-DialogBox .dialogBottomLeftInner { the inner element of the cell }
  • .dwt-DialogBox .dialogBottomCenter { the bottom center cell }
  • .dwt-DialogBox .dialogBottomCenterInner { the inner element of the cell }
  • .dwt-DialogBox .dialogBottomRight { the bottom right cell }
  • .dwt-DialogBox .dialogBottomRightInner { the inner element of the cell }

Example

{@example com.google.dwt.examples.DialogBoxExample}

Use in UiBinder Templates

DialogBox elements in {@link com.google.dwt.uibinder.client.UiBinder UiBinder} templates can have one widget child and one <g:caption> child. (Note the lower case "c", meant to signal that the caption is not a runtime object, and so cannot have a ui:field attribute.) The body of the caption can be html.

For example:

<g:DialogBox autoHide="true" modal="true">
  <g:caption><b>Caption text</b></g:caption>
  <g:HtmlPanel>
    Body text
    <g:Button ui:field='cancelButton'>Cancel</g:Button>
    <g:Button ui:field='okButton'>Okay</g:Button>
  </g:HtmlPanel>
</g:DialogBox>

You may also create your own header caption. The caption must implement {@link Caption}.

For example:

<g:DialogBox autoHide="true" modal="true">
  <-- foo is your prefix and Bar is a class that implements {@link Caption}-->
  <g:customCaption><foo:Bar/></g:customCaption>
  <g:HtmlPanel>
    Body text
    <g:Button ui:field='cancelButton'>Cancel</g:Button>
    <g:Button ui:field='okButton'>Okay</g:Button>
  </g:HtmlPanel>
</g:DialogBox>
class DialogBox extends DecoratedPopupPanel implements HasHtml, HasSafeHtml/*, MouseListener*/ {

 /**
  * The default style name.
  */
 static final String DEFAULT_STYLENAME = "dwt-DialogBox";

 Caption caption;
 bool dragging = false;
 int dragStartX, dragStartY;
 int windowWidth;
 int clientLeft;
 int clientTop;

 HandlerRegistration resizeHandlerRegistration;

//  /**
//   * Creates an empty dialog box. It should not be shown until its child widget
//   * has been added using {@link #add(Widget)}.
//   */
//  DialogBox() {
//    this(false);
//  }
//
//  /**
//   * Creates an empty dialog box specifying its "auto-hide" property. It should
//   * not be shown until its child widget has been added using
//   * {@link #add(Widget)}.
//   *
//   * @param autoHide <code>true</code> if the dialog should be automatically
//   *          hidden when the user clicks outside of it
//   */
//  DialogBox(bool autoHide) {
//    this(autoHide, true);
//  }
//
//  /**
//   * Creates an empty dialog box specifying its {@link Caption}. It should not
//   * be shown until its child widget has been added using {@link #add(Widget)}.
//   *
//   * @param captionWidget the widget that is the DialogBox's header.
//   */
//  DialogBox(Caption captionWidget) {
//    this(false, true, captionWidget);
//  }
//
//  /**
//   * Creates an empty dialog box specifying its "auto-hide" and "modal"
//   * properties. It should not be shown until its child widget has been added
//   * using {@link #add(Widget)}.
//   *
//   * @param autoHide <code>true</code> if the dialog should be automatically
//   *          hidden when the user clicks outside of it
//   * @param modal <code>true</code> if keyboard and mouse events for widgets not
//   *          contained by the dialog should be ignored
//   */
//  DialogBox(bool autoHide, bool modal) {
//    this(autoHide, modal, new CaptionImpl());
//  }

 /**
  *
  * Creates an empty dialog box specifying its "auto-hide", "modal" properties
  * and an implementation a custom {@link Caption}. It should not be shown
  * until its child widget has been added using {@link #add(Widget)}.
  *
  * @param autoHide <code>true</code> if the dialog should be automatically
  *          hidden when the user clicks outside of it
  * @param modal <code>true</code> if keyboard and mouse events for widgets not
  *          contained by the dialog should be ignored
  * @param captionWidget the widget that is the DialogBox's header.
  */
 DialogBox([bool autoHide = false, bool modal = true, Caption captionWidget = null]) : super(autoHide, modal, "dialog") {

   if (captionWidget == null) {
     captionWidget = new DialogBoxCaptionImpl();
   }
   captionWidget.asWidget().removeFromParent();
   caption = captionWidget;

   // Add the caption to the top row of the decorator panel. We need to
   // logically adopt the caption so we can catch mouse events.
   dart_html.Element td = getCellElement(0, 1);
   td.append(caption.asWidget().getElement());
   adopt(caption.asWidget());

   // Set the style name
   clearAndSetStyleName(DEFAULT_STYLENAME);

   windowWidth = Dom.getClientWidth();
   clientLeft = dart_html.document.body.offset.left ;// Document.get().getBodyOffsetLeft();
   clientTop = dart_html.document.body.offset.top; //Document.get().getBodyOffsetTop();

//    AllMouseHandlersAdapter mouseHandler = new AllMouseHandlersAdapter((DwtEvent event){
//      if (event is MouseDownEvent) {
//        beginDragging(event);
//      } else if (event is MouseMoveEvent) {
//        continueDragging(event);
//      } else if (event is MouseOutEvent) {
//        DialogBox.this.onMouseLeave(caption.asWidget());
//      } else if (event is MouseOverEvent) {
//        DialogBox.this.onMouseEnter(caption.asWidget());
//      } else if (event is MouseUpEvent) {
//        endDragging(event);
//      }
//    });
//    addDomHandler(mouseHandler, MouseDownEvent.TYPE);
//    addDomHandler(mouseHandler, MouseUpEvent.TYPE);
//    addDomHandler(mouseHandler, MouseMoveEvent.TYPE);
//    addDomHandler(mouseHandler, MouseOverEvent.TYPE);
//    addDomHandler(mouseHandler, MouseOutEvent.TYPE);
   addDomHandler(new MouseDownHandlerAdapter((MouseDownEvent event){
     beginDragging(event);
   }), MouseDownEvent.TYPE);
   addDomHandler(new MouseUpHandlerAdapter((MouseUpEvent event){
     endDragging(event);
   }), MouseUpEvent.TYPE);
   addDomHandler(new MouseMoveHandlerAdapter((MouseMoveEvent event){
     continueDragging(event);
   }), MouseMoveEvent.TYPE);
   addDomHandler(new MouseOverHandlerAdapter((MouseOverEvent event){
     //onMouseEnter(caption.asWidget());
   }), MouseOverEvent.TYPE);
   addDomHandler(new MouseOutHandlerAdapter((MouseOutEvent event){
     //onMouseLeave(caption.asWidget());
   }), MouseOutEvent.TYPE);
 }

 /**
  * Provides access to the dialog's caption.
  *
  * @return the logical caption for this dialog box
  */
 Caption getCaption() {
   return caption;
 }

 String get html => caption.html;

 String get text => caption.text;


 void hide([bool autoClosed = false]) {
   if (resizeHandlerRegistration != null) {
     resizeHandlerRegistration.removeHandler();
     resizeHandlerRegistration = null;
   }
   super.hide(autoClosed);
 }


 void onBrowserEvent(dart_html.Event event) {
   // If we're not yet dragging, only trigger mouse events if the event occurs
   // in the caption wrapper
   switch (IEvent.getTypeInt(event.type)) {
     case IEvent.ONMOUSEDOWN:
     case IEvent.ONMOUSEUP:
     case IEvent.ONMOUSEMOVE:
     case IEvent.ONMOUSEOVER:
     case IEvent.ONMOUSEOUT:
       if (!dragging && !isCaptionEvent(event)) {
         return;
       }
       break;
   }

   super.onBrowserEvent(event);
 }

 /**
  * Sets the html string inside the caption by calling its
  * {@link #setHtml(SafeHtml)} method.
  *
  * Use {@link #setWidget(Widget)} to set the contents inside the
  * {@link DialogBox}.
  *
  * @param html the object's new Html
  */
 void setHtml(SafeHtml html) {
   caption.html = html.toString();
 }

 /**
  * Sets the html string inside the caption by calling its
  * {@link #setHtml(SafeHtml)} method. Only known safe Html should be inserted
  * in here.
  *
  * Use {@link #setWidget(Widget)} to set the contents inside the
  * {@link DialogBox}.
  *
  * @param html the object's new Html
  */
 void set html(String val) {
   caption.html = SafeHtmlUtils.fromTrustedString(val).asString();
 }

 /**
  * Sets the text inside the caption by calling its {@link #setText(String)}
  * method.
  *
  * Use {@link #setWidget(Widget)} to set the contents inside the
  * {@link DialogBox}.
  *
  * @param text the object's new text
  */
 void set text(String val) {
   caption.text = val;
 }


 void show() {
   if (resizeHandlerRegistration == null) {
//      resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {
//        void onResize(ResizeEvent event) {
//          windowWidth = event.getWidth();
//        }
//      });
   }
   super.show();
 }

 /**
  * Called on mouse down in the caption area, begins the dragging loop by
  * turning on event capture.
  *
  * @see Dom#setCapture
  * @see #continueDragging
  * @param event the mouse down event that triggered dragging
  */
 void beginDragging(MouseDownEvent event) {
   if (Dom.getCaptureElement() == null) {
     /*
      * Need to check to make sure that we aren't already capturing an element
      * otherwise events will not fire as expected. If this check isn't here,
      * any class which extends custom button will not fire its click event for
      * example.
      */
     dragging = true;
     Dom.setCapture(getElement());
     dragStartX = event.getX();
     dragStartY = event.getY();
   }
 }

 /**
  * Called on mouse move in the caption area, continues dragging if it was
  * started by {@link #beginDragging}.
  *
  * @see #beginDragging
  * @see #endDragging
  * @param event the mouse move event that continues dragging
  */
 void continueDragging(MouseMoveEvent event) {
   if (dragging) {
     int absX = event.getX() + getAbsoluteLeft();
     int absY = event.getY() + getAbsoluteTop();

     // if the mouse is off the screen to the left, right, or top, don't
     // move the dialog box. This would let users lose dialog boxes, which
     // would be bad for modal popups.
     if (absX < clientLeft || absX >= windowWidth || absY < clientTop) {
       return;
     }

     setPopupPosition(absX - dragStartX, absY - dragStartY);
   }
 }


 void doAttachChildren() {
   try {
     super.doAttachChildren();
   } finally {
     // See comment in doDetachChildren for an explanation of this call
     caption.asWidget().onAttach();
   }
 }


 void doDetachChildren() {
   try {
     super.doDetachChildren();
   } finally {
     /*
      * We need to detach the caption specifically because it is not part of
      * the iterator of Widgets that the {@link SimplePanel} super class
      * returns. This is similar to a {@link ComplexPanel}, but we do not want
      * to expose the caption widget, as its just an internal implementation.
      */
     caption.asWidget().onDetach();
   }
 }

 /**
  * Called on mouse up in the caption area, ends dragging by ending event
  * capture.
  *
  * @param event the mouse up event that ended dragging
  *
  * @see Dom#releaseCapture
  * @see #beginDragging
  * @see #endDragging
  */
 void endDragging(MouseUpEvent event) {
   dragging = false;
   Dom.releaseCapture(getElement());
 }

 /**
  * <b>Affected Elements:</b>
  * <ul>
  * <li>-caption = text at the top of the {@link DialogBox}.</li>
  * <li>-content = the container around the content.</li>
  * </ul>
  *
  * @see UIObject#onEnsureDebugId(String)
  */

 void onPreviewNativeEvent(NativePreviewEvent event) {
   // We need to preventDefault() on mouseDown events (outside of the
   // DialogBox content) to keep text from being selected when it
   // is dragged.
   dart_html.Event nativeEvent = event.getNativeEvent();

   if (!event.isCanceled() && (IEvent.getTypeInt(nativeEvent.type) == IEvent.ONMOUSEDOWN)
       && isCaptionEvent(nativeEvent)) {
     nativeEvent.preventDefault();
   }

   super.onPreviewNativeEvent(event);
 }

 bool isCaptionEvent(dart_html.Event event) {
   dart_html.EventTarget target = event.target;
   if (target is dart_html.Element) {
     return Dom.isOrHasChild(getCellElement(0, 1).parent, target as dart_html.Element);
   }
   return false;
 }
}

Extends

UiObject > Widget > Panel > SimplePanel > PopupPanel > DecoratedPopupPanel > DialogBox

Implements

HasSafeHtml, HasHtml

Static Properties

final String DEFAULT_STYLENAME #

The default style name.

static final String DEFAULT_STYLENAME = "dwt-DialogBox"

Constructors

new DialogBox([bool autoHide = false, bool modal = true, Caption captionWidget = null]) #

Creates an empty dialog box specifying its "auto-hide", "modal" properties and an implementation a custom {@link Caption}. It should not be shown until its child widget has been added using {@link #add(Widget)}.

@param autoHide <code>true</code> if the dialog should be automatically

     hidden when the user clicks outside of it

@param modal <code>true</code> if keyboard and mouse events for widgets not

     contained by the dialog should be ignored

@param captionWidget the widget that is the DialogBox's header.

DialogBox([bool autoHide = false, bool modal = true, Caption captionWidget = null]) : super(autoHide, modal, "dialog") {

 if (captionWidget == null) {
   captionWidget = new DialogBoxCaptionImpl();
 }
 captionWidget.asWidget().removeFromParent();
 caption = captionWidget;

 // Add the caption to the top row of the decorator panel. We need to
 // logically adopt the caption so we can catch mouse events.
 dart_html.Element td = getCellElement(0, 1);
 td.append(caption.asWidget().getElement());
 adopt(caption.asWidget());

 // Set the style name
 clearAndSetStyleName(DEFAULT_STYLENAME);

 windowWidth = Dom.getClientWidth();
 clientLeft = dart_html.document.body.offset.left ;// Document.get().getBodyOffsetLeft();
 clientTop = dart_html.document.body.offset.top; //Document.get().getBodyOffsetTop();

//    AllMouseHandlersAdapter mouseHandler = new AllMouseHandlersAdapter((DwtEvent event){
//      if (event is MouseDownEvent) {
//        beginDragging(event);
//      } else if (event is MouseMoveEvent) {
//        continueDragging(event);
//      } else if (event is MouseOutEvent) {
//        DialogBox.this.onMouseLeave(caption.asWidget());
//      } else if (event is MouseOverEvent) {
//        DialogBox.this.onMouseEnter(caption.asWidget());
//      } else if (event is MouseUpEvent) {
//        endDragging(event);
//      }
//    });
//    addDomHandler(mouseHandler, MouseDownEvent.TYPE);
//    addDomHandler(mouseHandler, MouseUpEvent.TYPE);
//    addDomHandler(mouseHandler, MouseMoveEvent.TYPE);
//    addDomHandler(mouseHandler, MouseOverEvent.TYPE);
//    addDomHandler(mouseHandler, MouseOutEvent.TYPE);
 addDomHandler(new MouseDownHandlerAdapter((MouseDownEvent event){
   beginDragging(event);
 }), MouseDownEvent.TYPE);
 addDomHandler(new MouseUpHandlerAdapter((MouseUpEvent event){
   endDragging(event);
 }), MouseUpEvent.TYPE);
 addDomHandler(new MouseMoveHandlerAdapter((MouseMoveEvent event){
   continueDragging(event);
 }), MouseMoveEvent.TYPE);
 addDomHandler(new MouseOverHandlerAdapter((MouseOverEvent event){
   //onMouseEnter(caption.asWidget());
 }), MouseOverEvent.TYPE);
 addDomHandler(new MouseOutHandlerAdapter((MouseOutEvent event){
   //onMouseLeave(caption.asWidget());
 }), MouseOutEvent.TYPE);
}

Properties

AnimationType animType #

inherited from PopupPanel

If true, animate the opening of this popup from the center. If false, animate it open from top to bottom, and do not animate closing. Use false to animate menus.

AnimationType animType = AnimationType.CENTER

bool autoHide #

inherited from PopupPanel
bool autoHide = false

bool autoHideOnHistoryEvents #

inherited from PopupPanel
bool autoHideOnHistoryEvents = false

List<Element> autoHidePartners #

inherited from PopupPanel
List<dart_html.Element> autoHidePartners

Caption caption #

Caption caption

int clientLeft #

int clientLeft

int clientTop #

int clientTop

String desiredHeight #

inherited from PopupPanel
String desiredHeight

String desiredWidth #

inherited from PopupPanel
String desiredWidth

bool dragging #

bool dragging = false

int dragStartX #

int dragStartX

int dragStartY #

int dragStartX, dragStartY

int eventsToSink #

inherited from Widget

A set og events that should be sunk when the widget is attached to the DOM. (We delay the sinking of events to improve startup performance.) When the widget is attached, this is set is empty

Package protected to allow Composite to see it.

int eventsToSink = 0

Element glass #

inherited from PopupPanel

The glass element.

dart_html.Element glass

ResizeHandler glassResizer #

inherited from PopupPanel

Window resize handler used to keep the glass the proper size.

ResizeHandler glassResizer

String glassStyleName #

inherited from PopupPanel
String glassStyleName = "dwt-PopupPanelGlass"

HandlerRegistration historyHandlerRegistration #

inherited from PopupPanel
HandlerRegistration historyHandlerRegistration

String get html #

Gets this object's contents as HTML.

@return the object's HTML

docs inherited from HasHtml
String get html => caption.html;

void set html(String val) #

Sets the html string inside the caption by calling its {@link #setHtml(SafeHtml)} method. Only known safe Html should be inserted in here.

Use {@link #setWidget(Widget)} to set the contents inside the {@link DialogBox}.

@param html the object's new Html

void set html(String val) {
 caption.html = SafeHtmlUtils.fromTrustedString(val).asString();
}

int leftPosition #

inherited from PopupPanel
int leftPosition = -1
inherited from PopupPanel
bool autoHide = false, previewAllNativeEvents = false, modal = false

HandlerRegistration nativePreviewHandlerRegistration #

inherited from PopupPanel
HandlerRegistration nativePreviewHandlerRegistration

bool previewAllNativeEvents #

inherited from PopupPanel
bool autoHide = false, previewAllNativeEvents = false

ResizeAnimation resizeAnimation #

inherited from PopupPanel

The {@link ResizeAnimation} used to open and close the {@link PopupPanel}s.

ResizeAnimation resizeAnimation

HandlerRegistration resizeHandlerRegistration #

HandlerRegistration resizeHandlerRegistration

bool showing #

inherited from PopupPanel
bool autoHide = false, previewAllNativeEvents = false, modal = false, showing = false

String get text #

Gets this object's text.

@return the object's text

docs inherited from HasText
String get text => caption.text;

void set text(String val) #

Sets the text inside the caption by calling its {@link #setText(String)} method.

Use {@link #setWidget(Widget)} to set the contents inside the {@link DialogBox}.

@param text the object's new text

void set text(String val) {
 caption.text = val;
}

String get title #

inherited from UiObject

Gets the title associated with this object. The title is the 'tool-tip' displayed to users when they hover over the object.

@return the object's title

String get title => getElement().title;

void set title(String value) #

inherited from UiObject

Sets the element's title.

void set title(String value) {
 getElement().title = value;
}

int topPosition #

inherited from PopupPanel
int topPosition = -1

bool get visible #

inherited from PopupPanel

Determines whether or not this popup is visible. Note that this just checks the <code>visibility</code> style attribute, which is set in the {@link #setVisible(bool)} method. If you want to know if the popup is attached to the page, use {@link #isShowing()} instead.

@return <code>true</code> if the object is visible @see #setVisible(bool)

bool get visible => getElement().style.visibility != "hidden";

void set visible(bool vis) #

inherited from PopupPanel

Sets whether this object is visible. This method just sets the <code>visibility</code> style attribute. You need to call {@link #show()} to actually attached/detach the {@link PopupPanel} to the page.

@param visible <code>true</code> to show the object, <code>false</code> to

     hide it

@see #show() @see #hide()

void set visible(bool vis) {
 // We use visibility here instead of UiObject's default of display
 // Because the panel is absolutely positioned, this will not create
 // "holes" in displayed contents and it allows normal layout passes
 // to occur so the size of the PopupPanel can be reliably determined.
 Dom.setStyleAttribute(getElement(), "visibility", vis ? "visible"
     : "hidden");

 // If the PopupImpl creates an iframe shim, it's also necessary to hide it
 // as well.
 impl.setVisible(getElement(), vis);
 if (glass != null) {
   impl.setVisible(glass, vis);
   glass.style.visibility = vis ? "visible" : "hidden";
 }
}

Widget widget #

inherited from SimplePanel
Widget widget

int windowWidth #

int windowWidth

Methods

void add(Widget w) #

inherited from SimplePanel

Adds a widget to this panel.

@param w the child widget to be added

void add(Widget w) {
 // Can't add() more than one widget to a SimplePanel.
 if (getWidget() != null) {
   throw new Exception("SimplePanel can only contain one child widget");
 }
 setWidget(w);
}

HandlerRegistration addAttachHandler(AttachEventHandler handler) #

inherited from Widget

Adds an AttachEvent handler.

@param handler the handler @return the handler registration

HandlerRegistration addAttachHandler(AttachEventHandler handler) {
 return addHandler(handler, AttachEvent.TYPE);
}

void addAutoHidePartner(Element partner) #

inherited from PopupPanel

Mouse events that occur within an autoHide partner will not hide a panel set to autoHide.

@param partner the auto hide partner to add

void addAutoHidePartner(dart_html.Element partner) {
 assert (partner != null); // : "partner cannot be null";
 if (autoHidePartners == null) {
   autoHidePartners = new List<dart_html.Element>();
 }
 autoHidePartners.add(partner);
}

HandlerRegistration addBitlessDomHandler(EventHandler handler, DomEventType type) #

inherited from Widget

For <a href= "http://code.google.com/p/google-web-toolkit/wiki/UnderstandingMemoryLeaks"

browsers which do not leak</a>, adds a native event handler to the widget.

Note that, unlike the {@link #addDomHandler(EventHandler, com.google.gwt.event.dom.client.DomEvent.Type)} implementation, there is no need to attach the widget to the DOM in order to cause the event handlers to be attached.

@param <H> the type of handler to add @param type the event key @param handler the handler @return {@link HandlerRegistration} used to remove the handler

HandlerRegistration addBitlessDomHandler(EventHandler handler, DomEventType type) {
 assert (handler != null);; // : "handler must not be null";
 assert (type != null); // : "type must not be null";
 sinkBitlessEvent(type.eventName);
 return ensureHandlers().addHandler(type, handler);
}

HandlerRegistration addCloseHandler(CloseHandler handler) #

inherited from PopupPanel

Adds a {@link CloseEvent} handler.

@param handler the handler @return the registration for the event

docs inherited from HasCloseHandlers<PopupPanel>
HandlerRegistration addCloseHandler(CloseHandler handler) {
 return addHandler(handler, CloseEvent.TYPE);
}

HandlerRegistration addDomHandler(EventHandler handler, DomEventType type) #

inherited from Widget

Adds a native event handler to the widget and sinks the corresponding native event. If you do not want to sink the native event, use the generic addHandler method instead.

@param <H> the type of handler to add @param type the event key @param handler the handler @return {@link HandlerRegistration} used to remove the handler

HandlerRegistration addDomHandler(EventHandler handler, DomEventType type) {
 assert (handler != null); // : "handler must not be null";
 assert (type != null); // : "type must not be null";
 int typeInt = IEvent.getTypeInt(type.eventName);
 if (typeInt == -1) {
   sinkBitlessEvent(type.eventName);
 } else {
   sinkEvents(typeInt);
 }
 return ensureHandlers().addHandler(type, handler);
}

HandlerRegistration addHandler(EventHandler handler, EventType<EventHandler> type) #

inherited from Widget

Adds this handler to the widget.

@param <H> the type of handler to add @param type the event type @param handler the handler @return {@link HandlerRegistration} used to remove the handler

HandlerRegistration addHandler(EventHandler handler, EventType<EventHandler> type) {
 return ensureHandlers().addHandler(type, handler);
}

void addIsWidget(IsWidget child) #

inherited from Panel
void addIsWidget(IsWidget child) {
 this.add(Widget.asWidgetOrNull(child));
}

void addStyleDependentName(String styleSuffix) #

inherited from UiObject

Adds a dependent style name by specifying the style name's suffix. The actual form of the style name that is added is:

getStylePrimaryName() + '-' + styleSuffix

@param styleSuffix the suffix of the dependent style to be added. @see #setStylePrimaryName(String) @see #removeStyleDependentName(String) @see #setStyleDependentName(String, boolean) @see #addStyleName(String)

void addStyleDependentName(String styleSuffix) {
 setStyleDependentName(styleSuffix, true);
}

void addStyleName(String style) #

inherited from UiObject

Adds a secondary or dependent style name to this object. A secondary style name is an additional style name that is, in HTML/CSS terms, included as a space-separated token in the value of the CSS <code>class</code> attribute for this object's root element.

The most important use for this method is to add a special kind of secondary style name called a dependent style name. To add a dependent style name, use {@link #addStyleDependentName(String)}, which will prefix the 'style' argument with the result of {@link #k()} (followed by a '-'). For example, suppose the primary style name is gwt-TextBox. If the following method is called as obj.setReadOnly(true):

public void setReadOnly(boolean readOnly) {
  isReadOnlyMode = readOnly;

// Create a dependent style name. String readOnlyStyle = "readonly";

if (readOnly) {

addStyleDependentName(readOnlyStyle);

} else {

removeStyleDependentName(readOnlyStyle);

} }</pre>

then both of the CSS style rules below will be applied:

// This rule is based on the primary style name and is always active. .gwt-TextBox { font-size: 12pt; }

// This rule is based on a dependent style name that is only active // when the widget has called addStyleName(getStylePrimaryName() + // "-readonly"). .gwt-TextBox-readonly { background-color: lightgrey; border: none; }</pre>

The code can also be simplified with {@link #setStyleDependentName(String, boolean)}:

public void setReadOnly(boolean readOnly) {
  isReadOnlyMode = readOnly;
  setStyleDependentName("readonly", readOnly);
}

Dependent style names are powerful because they are automatically updated whenever the primary style name changes. Continuing with the example above, if the primary style name changed due to the following call:

setStylePrimaryName("my-TextThingy");

then the object would be re-associated with following style rules, removing those that were shown above.

.my-TextThingy {
  font-size: 20pt;
}

.my-TextThingy-readonly { background-color: red; border: 2px solid yellow; }</pre>

Secondary style names that are not dependent style names are not automatically updated when the primary style name changes.

@param style the secondary style name to be added @see UIObject @see #removeStyleName(String)

void addStyleName(String style) {
 setStyleName(style, true);
}

void adopt(Widget child) #

inherited from Panel

Finalize the attachment of a Widget to this Panel. This method is the <b>last</b> step in adding or inserting a Widget into a Panel, and should be called after physical attachment in the DOM is complete. This Panel becomes the parent of the child Widget, and the child will now fire its {@link Widget#onAttach()} event if this Panel is currently attached.

@param child the widget to be adopted @see #add(Widget)

void adopt(Widget child) {
 assert (child.getParent() == null);
 child.setParent(this);
}

Widget asWidget() #

inherited from Widget

Returns the Widget aspect of the receiver.

Widget asWidget() {
 return this;
}

void beginDragging(MouseDownEvent event) #

Called on mouse down in the caption area, begins the dragging loop by turning on event capture.

@see Dom#setCapture @see #continueDragging @param event the mouse down event that triggered dragging

void beginDragging(MouseDownEvent event) {
 if (Dom.getCaptureElement() == null) {
   /*
    * Need to check to make sure that we aren't already capturing an element
    * otherwise events will not fire as expected. If this check isn't here,
    * any class which extends custom button will not fire its click event for
    * example.
    */
   dragging = true;
   Dom.setCapture(getElement());
   dragStartX = event.getX();
   dragStartY = event.getY();
 }
}

void blur(Element elt) #

inherited from PopupPanel

Remove focus from an dart_html.Element.

@param elt The dart_html.Element on which <code>blur()</code> will be invoked

void blur(dart_html.Element elt) {
 // Issue 2390: blurring the body causes IE to disappear to the background
 if (elt.blur != null && elt != dart_html.document.body) {
   elt.blur();
 }
}

void center() #

inherited from PopupPanel

Centers the popup in the browser window and shows it. If the popup was already showing, then the popup is centered.

void center() {
 bool initiallyShowing = showing;
 bool initiallyAnimated = _isAnimationEnabled;

 if (!initiallyShowing) {
   visible = false;
   setAnimationEnabled(false);
   show();
 }

 // If left/top are set from a previous center() call, and our content
 // has changed, we may get a bogus getOffsetWidth because our new content
 // is wrapping (giving a lower offset width) then it would without the
 // previous left. Setting left/top back to 0 avoids this.
 dart_html.Element elem = getElement();
 elem.style.left = "0px";
 elem.style.top = "0px";

 int left = (Dom.getClientWidth() - getOffsetWidth()) >> 1;
 int top = (Dom.getClientHeight() - getOffsetHeight()) >> 1;
 setPopupPosition(dart_math.max(Dom.getScrollLeft() + left, 0),
     dart_math.max(Dom.getScrollTop() + top, 0));

 if (!initiallyShowing) {
   setAnimationEnabled(initiallyAnimated);
   // Run the animation. The popup is already visible, so we can skip the
   // call to setState.
   if (initiallyAnimated) {
     impl.setClip(getElement(), "rect(0px, 0px, 0px, 0px)");
     visible = true;
     resizeAnimation.run(ANIMATION_DURATION);
   } else {
     visible = true;
   }
 }
}

void clear() #

inherited from DecoratedPopupPanel

Removes all child widgets.

docs inherited from Panel
void clear() {
 _decPanel.clear();
}

void clearAndSetStyleName(String style) #

inherited from UiObject

Clears all of the object's style names and sets it to the given style. You should normally use {@link #setStylePrimaryName(String)} unless you wish to explicitly remove all existing styles.

@param style the new style name @see #setStylePrimaryName(String)

void clearAndSetStyleName(String style) {
 setElementStyleName(getStyleElement(), style);
}

void continueDragging(MouseMoveEvent event) #

Called on mouse move in the caption area, continues dragging if it was started by {@link #beginDragging}.

@see #beginDragging @see #endDragging @param event the mouse move event that continues dragging

void continueDragging(MouseMoveEvent event) {
 if (dragging) {
   int absX = event.getX() + getAbsoluteLeft();
   int absY = event.getY() + getAbsoluteTop();

   // if the mouse is off the screen to the left, right, or top, don't
   // move the dialog box. This would let users lose dialog boxes, which
   // would be bad for modal popups.
   if (absX < clientLeft || absX >= windowWidth || absY < clientTop) {
     return;
   }

   setPopupPosition(absX - dragStartX, absY - dragStartY);
 }
}

EventBus createEventBus() #

inherited from Widget

Creates the SimpleEventBus used by this Widget. You can override this method to create a custom EventBus.

@return the EventBus you want to use.

EventBus createEventBus() {
 return new SimpleEventBus();
}

void delegateEvent(Widget target, DwtEvent event) #

inherited from Widget

Fires an event on a child widget. Used to delegate the handling of an event from one widget to another.

@param event the event @param target fire the event on the given target

void delegateEvent(Widget target, DwtEvent event) {
 target.fireEvent(event);
}

void doAttachChildren() #

If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call {@link #onAttach()} for each of its child widgets.

@see #onAttach()

docs inherited from Widget
void doAttachChildren() {
 try {
   super.doAttachChildren();
 } finally {
   // See comment in doDetachChildren for an explanation of this call
   caption.asWidget().onAttach();
 }
}

void doDetachChildren() #

If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call {@link #onDetach()} for each of its child widgets.

@see #onDetach()

docs inherited from Widget
void doDetachChildren() {
 try {
   super.doDetachChildren();
 } finally {
   /*
    * We need to detach the caption specifically because it is not part of
    * the iterator of Widgets that the {@link SimplePanel} super class
    * returns. This is similar to a {@link ComplexPanel}, but we do not want
    * to expose the caption widget, as its just an internal implementation.
    */
   caption.asWidget().onDetach();
 }
}

void endDragging(MouseUpEvent event) #

Called on mouse up in the caption area, ends dragging by ending event capture.

@param event the mouse up event that ended dragging

@see Dom#releaseCapture @see #beginDragging @see #endDragging

void endDragging(MouseUpEvent event) {
 dragging = false;
 Dom.releaseCapture(getElement());
}

EventBus ensureHandlers() #

inherited from Widget

Ensures the existence of the event bus.

@return the EventBus.

EventBus ensureHandlers() {
 return _eventBus == null ? _eventBus = createEventBus() : _eventBus;
}

bool eventTargetsPartner(Event event) #

inherited from PopupPanel

Does the event target one of the partner elements?

@param event the event @return true if the event targets a partner

bool eventTargetsPartner(dart_html.Event event) {
 if (autoHidePartners == null) {
   return false;
 }

 dart_html.EventTarget target = event.target;
 if (target is dart_html.Element) {
   for (dart_html.Element elem in autoHidePartners) {
     if (Dom.isOrHasChild(elem, target as dart_html.Element)) {
       return true;
     }
   }
 }
 return false;
}

bool eventTargetsPopup(Event event) #

inherited from PopupPanel

Does the event target this popup?

@param event the event @return true if the event targets the popup

bool eventTargetsPopup(dart_html.Event event) {
 dart_html.EventTarget target = event.target;
 if (target is dart_html.Element) {
   return Dom.isOrHasChild(getElement(), target as dart_html.Element);
 }
 return false;
}

double extractLengthValue(String s) #

inherited from UiObject

Intended to be used to pull the value out of a CSS length. If the value is "auto" or "inherit", 0 will be returned.

@param s The CSS length string to extract @return The leading numeric portion of <code>s</code>, or 0 if "auto" or

    "inherit" are passed in.
double extractLengthValue(String s) {
 if (s == "auto" || s == "inherit" || s == "") {
   return 0.0;
 } else {
   // numberRegex divides the string into a leading numeric portion
   // followed by an arbitrary portion.
   if(numberRegex.hasMatch(s)) {
     // Extract the leading numeric portion of string
     s = numberRegex.firstMatch(s)[0];
   }
   return double.parse(s);
 }
}

void fireEvent(DwtEvent event) #

inherited from Widget

Fires the given event to the handlers listening to the event's type.

Any exceptions thrown by handlers will be bundled into a UmbrellaException and then re-thrown after all handlers have completed. An exception thrown by a handler will not prevent other handlers from executing.

@param event the event

void fireEvent(DwtEvent event) {
//    if (_eventBus != null) {
//      _eventBus.fireEvent(event);
//    }
 if (_eventBus != null) {
   // If it not live we should revive it.
   if (!event.isLive()) {
     event.revive();
   }
   Object oldSource = event.getSource();
   event.overrideSource(getElement());
   try {

     // May throw an UmbrellaException.
     _eventBus.fireEventFromSource(event, getElement());
   } on UmbrellaException catch (e) {
     throw new UmbrellaException(e.causes);
   } finally {
     if (oldSource == null) {
       // This was my event, so I should kill it now that I'm done.
       event.kill();
     } else {
       // Restoring the source for the next handler to use.
       event.overrideSource(oldSource);
     }
   }
 }
}

int getAbsoluteLeft() #

inherited from UiObject

Gets the object's absolute left position in pixels, as measured from the browser window's client area.

@return the object's absolute left position

int getAbsoluteLeft() {
 return Dom.getAbsoluteLeft(getElement());
}

int getAbsoluteTop() #

inherited from UiObject

Gets the object's absolute top position in pixels, as measured from the browser window's client area.

@return the object's absolute top position

int getAbsoluteTop() {
 return Dom.getAbsoluteTop(getElement());
}

Caption getCaption() #

Provides access to the dialog's caption.

@return the logical caption for this dialog box

Caption getCaption() {
 return caption;
}

Element getCellElement(int row, int cell) #

inherited from DecoratedPopupPanel

Get a specific Element from the panel.

@param row the row index @param cell the cell index @return the Element at the given row and cell

dart_html.Element getCellElement(int row, int cell) {
 return _decPanel.getCellElement(row, cell);
}

Element getContainerElement() #

inherited from PopupPanel

Override this method to specify that an element other than the root element be the container for the panel's child widget. This can be useful when you want to create a simple panel that decorates its contents.

Note that this method continues to return the {@link com.google.gwt.user.client.Element} class defined in the <code>User</code> module to maintain backwards compatibility.

@return the element to be used as the panel's container

docs inherited from SimplePanel
dart_html.Element getContainerElement() {
 return impl.getContainerElement(getPopupImplElement());
}

Element getElement() #

inherited from UiObject

Gets this object's browser element.

dart_html.Element getElement() {
 assert (_element != null); // : MISSING_ELEMENT_ERROR;
 return _element;
}

EventBus getEventBus() #

inherited from Widget

Return EventBus.

EventBus getEventBus() {
 return _eventBus;
}

Element getGlassElement() #

inherited from PopupPanel

Get the glass element used by this {@link PopupPanel}. The element is not created until it is enabled via {@link #setGlassEnabled(bool)}.

@return the glass element, or null if not created

dart_html.Element getGlassElement() {
 return glass;
}

String getGlassStyleName() #

inherited from PopupPanel

Gets the style name to be used on the glass element. By default, this is "gwt-PopupPanelGlass".

@return the glass element's style name

String getGlassStyleName() {
 return glassStyleName;
}

Object getLayoutData() #

inherited from Widget

Gets the panel-defined layout data associated with this widget.

@return the widget's layout data @see #setLayoutData

Object getLayoutData() {
 return _layoutData;
}

int getOffsetHeight() #

inherited from PopupPanel

Gets the panel's offset height in pixels. Calls to {@link #setHeight(String)} before the panel's child widget is set will not influence the offset height.

@return the object's offset height

int getOffsetHeight() {
 return super.getOffsetHeight();
}

int getOffsetWidth() #

inherited from PopupPanel

Gets the panel's offset width in pixels. Calls to {@link #setWidth(String)} before the panel's child widget is set will not influence the offset width.

@return the object's offset width

int getOffsetWidth() {
 return super.getOffsetWidth();
}

Widget getParent() #

inherited from Widget

Gets this widget's parent panel.

@return the widget's parent panel

Widget getParent() {
 return _parent;
}

Element getPopupImplElement() #

inherited from PopupPanel

Get the element that {@link PopupImpl} uses. PopupImpl creates an element that goes inside of the outer element, so all methods in PopupImpl are relative to the first child of the outer element, not the outer element itself.

@return the dart_html.Element that {@link PopupImpl} creates and expects

dart_html.Element getPopupImplElement() {
 return super.getContainerElement().firstChild;
}

int getPopupLeft() #

inherited from PopupPanel

Gets the popup's left position relative to the browser's client area.

@return the popup's left position

int getPopupLeft() {
 return Dom.getAbsoluteLeft(getElement());
}

int getPopupTop() #

inherited from PopupPanel

Gets the popup's top position relative to the browser's client area.

@return the popup's top position

int getPopupTop() {
 return Dom.getAbsoluteTop(getElement());
}

Element getStyleElement() #

inherited from PopupPanel

Template method that returns the element to which style names will be applied. By default it returns the root element, but this method may be overridden to apply styles to a child element.

@return the element to which style names will be applied

docs inherited from UiObject
dart_html.Element getStyleElement() {
 return impl.getStyleElement(getPopupImplElement());
}

String getStyleName() #

inherited from UiObject

Gets all of the object's style names, as a space-separated list. If you wish to retrieve only the primary style name, call {@link #getStylePrimaryName()}.

@return the objects's space-separated style names @see #getStylePrimaryName()

String getStyleName() {
 return getElementStyleName(getStyleElement());
}

String getStylePrimaryName() #

inherited from UiObject

Gets the primary style name associated with the object.

@return the object's primary style name @see #setStyleName(String) @see #addStyleName(String) @see #removeStyleName(String)

String getStylePrimaryName() {
 return getElementStylePrimaryName(getStyleElement());
}

String getTitle() #

inherited from PopupPanel
String getTitle() {
 return Dom.getElementProperty(getContainerElement(), "title");
}

Widget getWidget() #

inherited from DecoratedPopupPanel

Gets the panel's child widget.

@return the child widget, or <code>null</code> if none is present

docs inherited from SimplePanel
Widget getWidget() {
 return _decPanel.getWidget();
}

void hide([bool autoClosed = false]) #

Hides the popup and detaches it from the page. This has no effect if it is not currently showing.

@param autoClosed the value that will be passed to

     {@link CloseHandler#onClose(CloseEvent)} when the popup is closed
docs inherited from PopupPanel
void hide([bool autoClosed = false]) {
 if (resizeHandlerRegistration != null) {
   resizeHandlerRegistration.removeHandler();
   resizeHandlerRegistration = null;
 }
 super.hide(autoClosed);
}

bool isAnimationEnabled() #

inherited from PopupPanel

Returns true if animations are enabled, false if not.

docs inherited from HasAnimation
bool isAnimationEnabled() {
 return _isAnimationEnabled;
}

bool isAttached() #

inherited from Widget

Returns whether or not the receiver is attached to the {@link com.google.gwt.dom.client.Document Document}'s {@link com.google.gwt.dom.client.BodyElement BodyElement}.

@return true if attached, false otherwise

bool isAttached() {
 return _attached;
}

bool isAutoHideEnabled() #

inherited from PopupPanel

Returns <code>true</code> if the popup should be automatically hidden when the user clicks outside of it.

@return true if autoHide is enabled, false if disabled

bool isAutoHideEnabled() {
 return autoHide;
}

bool isAutoHideOnHistoryEventsEnabled() #

inherited from PopupPanel

Returns <code>true</code> if the popup should be automatically hidden when the history token changes, such as when the user presses the browser's back button.

@return true if enabled, false if disabled

bool isAutoHideOnHistoryEventsEnabled() {
 return autoHideOnHistoryEvents;
}

bool isCaptionEvent(Event event) #

bool isCaptionEvent(dart_html.Event event) {
 dart_html.EventTarget target = event.target;
 if (target is dart_html.Element) {
   return Dom.isOrHasChild(getCellElement(0, 1).parent, target as dart_html.Element);
 }
 return false;
}

bool isGlassEnabled() #

inherited from PopupPanel

Returns <code>true</code> if a glass element will be displayed under the {@link PopupPanel}.

@return true if enabled

bool isGlassEnabled() {
 return _isGlassEnabled;
}

bool isModal() #

inherited from PopupPanel

Returns <code>true</code> if keyboard or mouse events that do not target the PopupPanel or its children should be ignored.

@return true if popup is modal, false if not

bool isModal() {
 return modal;
}

bool isOrWasAttached() #

inherited from Widget

Has this widget ever been attached?

@return true if this widget ever been attached to the DOM, false otherwise

bool isOrWasAttached() {
 return eventsToSink == -1;
}

bool isPreviewingAllNativeEvents() #

inherited from PopupPanel

Returns <code>true</code> if the popup should preview all events, even if the event has already been consumed by another popup.

@return true if previewAllNativeEvents is enabled, false if disabled

bool isPreviewingAllNativeEvents() {
 return previewAllNativeEvents;
}

bool isShowing() #

inherited from PopupPanel

Determines whether or not this popup is showing.

@return <code>true</code> if the popup is showing @see #show() @see #hide()

bool isShowing() {
 return showing;
}

Iterator<Widget> iterator() #

inherited from DecoratedPopupPanel

Returns an Iterator that iterates over this Iterable object.

docs inherited from HasWidgets
Iterator<Widget> iterator() {
 return _decPanel.iterator();
}

void maybeUpdateSize() #

inherited from PopupPanel

We control size by setting our child widget's size. However, if we don't currently have a child, we record the size the user wanted so that when we do get a child, we can set it correctly. Until size is explicitly cleared, any child put into the popup will be given that size.

void maybeUpdateSize() {
 // For subclasses of PopupPanel, we want the default behavior of setWidth
 // and setHeight to change the dimensions of PopupPanel's child widget.
 // We do this because PopupPanel's child widget is the first widget in
 // the hierarchy which provides structure to the panel. DialogBox is
 // an example of this. We want to set the dimensions on DialogBox's
 // FlexTable, which is PopupPanel's child widget. However, it is not
 // DialogBox's child widget. To make sure that we are actually getting
 // PopupPanel's child widget, we have to use super.getWidget().
 Widget w = super.getWidget();
 if (w != null) {
   if (desiredHeight != null) {
     w.setHeight(desiredHeight);
   }
   if (desiredWidth != null) {
     w.setWidth(desiredWidth);
   }
 }
}

void onAttach() #

inherited from Widget

This method is called when a widget is attached to the browser's document. To receive notification after a Widget has been added to the document, override the {@link #onLoad} method or use {@link #addAttachHandler}.

It is strongly recommended that you override {@link #onLoad()} or {@link #doAttachChildren()} instead of this method to avoid inconsistencies between logical and physical attachment states.

Subclasses that override this method must call super.onAttach() to ensure that the Widget has been attached to its underlying Element.

@throws IllegalStateException if this widget is already attached @see #onLoad() @see #doAttachChildren()

void onAttach() {
 if (isAttached()) {
   throw new Exception("Should only call onAttach when the widget is detached from the browser's document");
 }

 _attached = true;

 // Event hookup code
 Dom.setEventListener(getElement(), this);
 int bitsToAdd = eventsToSink;
 eventsToSink = -1;
 if (bitsToAdd > 0) {
   sinkEvents(bitsToAdd);
 }
 doAttachChildren();

 // onLoad() gets called only *after* all of the children are attached and
 // the attached flag is set. This allows widgets to be notified when they
 // are fully attached, and panels when all of their children are attached.
 onLoad();
 AttachEvent.fire(this, true);
}

void onBrowserEvent(Event event) #

Fired whenever a browser event is received.

@param event the event received

TODO

docs inherited from Widget
void onBrowserEvent(dart_html.Event event) {
 // If we're not yet dragging, only trigger mouse events if the event occurs
 // in the caption wrapper
 switch (IEvent.getTypeInt(event.type)) {
   case IEvent.ONMOUSEDOWN:
   case IEvent.ONMOUSEUP:
   case IEvent.ONMOUSEMOVE:
   case IEvent.ONMOUSEOVER:
   case IEvent.ONMOUSEOUT:
     if (!dragging && !isCaptionEvent(event)) {
       return;
     }
     break;
 }

 super.onBrowserEvent(event);
}

void onDetach() #

inherited from Widget

This method is called when a widget is detached from the browser's document. To receive notification before a Widget is removed from the document, override the {@link #onUnload} method or use {@link #addAttachHandler}.

It is strongly recommended that you override {@link #onUnload()} or {@link #doDetachChildren()} instead of this method to avoid inconsistencies between logical and physical attachment states.

Subclasses that override this method must call super.onDetach() to ensure that the Widget has been detached from the underlying Element. Failure to do so will result in application memory leaks due to circular references between DOM Elements and JavaScript objects.

@throws IllegalStateException if this widget is already detached @see #onUnload() @see #doDetachChildren()

void onDetach() {
 if (!isAttached()) {
   throw new Exception("Should only call onDetach when the widget is attached to the browser's document");
 }

 try {
   // onUnload() gets called *before* everything else (the opposite of
   // onLoad()).
   onUnload();
   AttachEvent.fire(this, false);
 } finally {
   // Put this in a finally, just in case onUnload throws an exception.
   try {
     doDetachChildren();
   } finally {
     // Put this in a finally, in case doDetachChildren throws an exception.
     Dom.setEventListener(getElement(), null);
     _attached = false;
   }
 }
}

bool onEventPreview(NativePreviewEvent event) #

inherited from PopupPanel

@deprecated Use {@link #onPreviewNativeEvent} instead

bool onEventPreview(NativePreviewEvent event) {
 return true;
}

void onLoad() #

inherited from Widget

This method is called immediately after a widget becomes attached to the browser's document.

void onLoad() {
}

void onPreviewNativeEvent(NativePreviewEvent event) #

Affected Elements:
  • -caption = text at the top of the {@link DialogBox}.
  • -content = the container around the content.

@see UIObject#onEnsureDebugId(String)

void onPreviewNativeEvent(NativePreviewEvent event) {
 // We need to preventDefault() on mouseDown events (outside of the
 // DialogBox content) to keep text from being selected when it
 // is dragged.
 dart_html.Event nativeEvent = event.getNativeEvent();

 if (!event.isCanceled() && (IEvent.getTypeInt(nativeEvent.type) == IEvent.ONMOUSEDOWN)
     && isCaptionEvent(nativeEvent)) {
   nativeEvent.preventDefault();
 }

 super.onPreviewNativeEvent(event);
}

void onUnload() #

inherited from PopupPanel

This method is called immediately before a widget will be detached from the browser's document.

docs inherited from Widget
void onUnload() {
 super.onUnload();

 // Just to be sure, we perform cleanup when the popup is unloaded (i.e.
 // removed from the Dom). This is normally taken care of in hide(), but it
 // can be missed if someone removes the popup directly from the RootPanel.
 if (isShowing()) {
   resizeAnimation.setState(false, true);
 }
}

void orphan(Widget child) #

inherited from Panel

This method must be called as part of the remove method of any Panel. It ensures that the Widget's parent is cleared. This method should be called after verifying that the child Widget is an existing child of the Panel, but before physically removing the child Widget from the DOM. The child will now fire its {@link Widget#onDetach()} event if this Panel is currently attached.

Calls to {@link #orphan(Widget)} should be wrapped in a try/finally block to ensure that the widget is physically detached even if orphan throws an exception.

@param child the widget to be disowned @see #add(Widget)

void orphan(Widget child) {
 assert (child.getParent() == this);
 child.setParent(null);
}

void position(UiObject relativeObject, int offsetWidth, int offsetHeight) #

inherited from PopupPanel

Positions the popup, called after the offset width and height of the popup are known.

@param relativeObject the ui object to position relative to @param offsetWidth the drop down's offset width @param offsetHeight the drop down's offset height

void position(final UiObject relativeObject, int offsetWidth,
   int offsetHeight) {
 // Calculate left position for the popup. The computation for
 // the left position is bidi-sensitive.

 int textBoxOffsetWidth = relativeObject.getOffsetWidth();

 // Compute the difference between the popup's width and the
 // textbox's width
 int offsetWidthDiff = offsetWidth - textBoxOffsetWidth;

 int left;

 if (LocaleInfo.getCurrentLocale().isRTL()) { // RTL case

   int textBoxAbsoluteLeft = relativeObject.getAbsoluteLeft();

   // Right-align the popup. Note that this computation is
   // valid in the case where offsetWidthDiff is negative.
   left = textBoxAbsoluteLeft - offsetWidthDiff;

   // If the suggestion popup is not as wide as the text box, always
   // align to the right edge of the text box. Otherwise, figure out whether
   // to right-align or left-align the popup.
   if (offsetWidthDiff > 0) {

     // Make sure scrolling is taken into account, since
     // box.getAbsoluteLeft() takes scrolling into account.
     int windowRight = Dom.getClientWidth() + Dom.getScrollLeft();
     int windowLeft = Dom.getScrollLeft();

     // Compute the left value for the right edge of the textbox
     int textBoxLeftValForRightEdge = textBoxAbsoluteLeft
         + textBoxOffsetWidth;

     // Distance from the right edge of the text box to the right edge
     // of the window
     int distanceToWindowRight = windowRight - textBoxLeftValForRightEdge;

     // Distance from the right edge of the text box to the left edge of the
     // window
     int distanceFromWindowLeft = textBoxLeftValForRightEdge - windowLeft;

     // If there is not enough space for the overflow of the popup's
     // width to the right of the text box and there IS enough space for the
     // overflow to the right of the text box, then left-align the popup.
     // However, if there is not enough space on either side, stick with
     // right-alignment.
     if (distanceFromWindowLeft < offsetWidth
         && distanceToWindowRight >= offsetWidthDiff) {
       // Align with the left edge of the text box.
       left = textBoxAbsoluteLeft;
     }
   }
 } else { // LTR case

   // Left-align the popup.
   left = relativeObject.getAbsoluteLeft();

   // If the suggestion popup is not as wide as the text box, always align to
   // the left edge of the text box. Otherwise, figure out whether to
   // left-align or right-align the popup.
   if (offsetWidthDiff > 0) {
     // Make sure scrolling is taken into account, since
     // box.getAbsoluteLeft() takes scrolling into account.
     int windowRight = Dom.getClientWidth() + Dom.getScrollLeft();
     int windowLeft = Dom.getScrollLeft();

     // Distance from the left edge of the text box to the right edge
     // of the window
     int distanceToWindowRight = windowRight - left;

     // Distance from the left edge of the text box to the left edge of the
     // window
     int distanceFromWindowLeft = left - windowLeft;

     // If there is not enough space for the overflow of the popup's
     // width to the right of hte text box, and there IS enough space for the
     // overflow to the left of the text box, then right-align the popup.
     // However, if there is not enough space on either side, then stick with
     // left-alignment.
     if (distanceToWindowRight < offsetWidth
         && distanceFromWindowLeft >= offsetWidthDiff) {
       // Align with the right edge of the text box.
       left -= offsetWidthDiff;
     }
   }
 }

 // Calculate top position for the popup

 int top = relativeObject.getAbsoluteTop();

 // Make sure scrolling is taken into account, since
 // box.getAbsoluteTop() takes scrolling into account.
 int windowTop = Dom.getScrollTop();
 int windowBottom = Dom.getScrollTop() + Dom.getClientHeight();

 // Distance from the top edge of the window to the top edge of the
 // text box
 int distanceFromWindowTop = top - windowTop;

 // Distance from the bottom edge of the window to the bottom edge of
 // the text box
 int distanceToWindowBottom = windowBottom
     - (top + relativeObject.getOffsetHeight());

 // If there is not enough space for the popup's height below the text
 // box and there IS enough space for the popup's height above the text
 // box, then then position the popup above the text box. However, if there
 // is not enough space on either side, then stick with displaying the
 // popup below the text box.
 if (distanceToWindowBottom < offsetHeight
     && distanceFromWindowTop >= offsetHeight) {
   top -= offsetHeight;
 } else {
   // Position above the text box
   top += relativeObject.getOffsetHeight();
 }
 setPopupPosition(left, top);
}

void previewNativeEvent(NativePreviewEvent event) #

inherited from PopupPanel

Preview the {@link dart_html.Event}.

@param event the {@link dart_html.Event}

void previewNativeEvent(NativePreviewEvent event) {
 // If the event has been canceled or consumed, ignore it
 if (event.isCanceled() || (!previewAllNativeEvents && event.isConsumed())) {
   // We need to ensure that we cancel the event even if its been consumed so
   // that popups lower on the stack do not auto hide
   if (modal) {
     event.cancel();
   }
   return;
 }

 // Fire the event hook and return if the event is canceled
 onPreviewNativeEvent(event);
 if (event.isCanceled()) {
   return;
 }

 // If the event targets the popup or the partner, consume it
 dart_html.Event nativeEvent = event.getNativeEvent();
 bool eventTargetsPopupOrPartner = eventTargetsPopup(nativeEvent) || eventTargetsPartner(nativeEvent);
 if (eventTargetsPopupOrPartner) {
   event.consume();
 }

 // Cancel the event if it doesn't target the modal popup. Note that the
 // event can be both canceled and consumed.
 if (modal) {
   event.cancel();
 }

 // Switch on the event type
 int type = IEvent.getTypeInt(nativeEvent.type);
 switch (type) {
//      case IEvent.ONKEYDOWN:
//        if (!onKeyDownPreview((char) nativeEvent.getKeyCode(),
//            KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
//          event.cancel();
//        }
//        return;
//      case IEvent.ONKEYUP:
//        if (!onKeyUpPreview((char) nativeEvent.getKeyCode(),
//            KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
//          event.cancel();
//        }
//        return;
//      case IEvent.ONKEYPRESS:
//        if (!onKeyPressPreview((char) nativeEvent.getKeyCode(),
//            KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
//          event.cancel();
//        }
//        return;
//
   case IEvent.ONMOUSEDOWN:
     // Don't eat events if event capture is enabled, as this can
     // interfere with dialog dragging, for example.
     if (Dom.getCaptureElement() != null) {
       event.consume();
       return;
     }

     if (!eventTargetsPopupOrPartner && autoHide) {
       hide(true);
       return;
     }
     break;
   case IEvent.ONMOUSEUP:
   case IEvent.ONMOUSEMOVE:
   case IEvent.ONCLICK:
   case IEvent.ONDBLCLICK:
     // Don't eat events if event capture is enabled, as this can
     // interfere with dialog dragging, for example.
     if (Dom.getCaptureElement() != null) {
       event.consume();
       return;
     }
     break;

   case IEvent.ONFOCUS:
     dart_html.Element target = nativeEvent.target as dart_html.Element;
     if (modal && !eventTargetsPopupOrPartner && (target != null)) {
       blur(target);
       event.cancel();
       return;
     }
     break;
 }
}

bool remove(Widget w) #

inherited from DecoratedPopupPanel

Removes a child widget.

How to Override this Method

There are several important things that must take place in the correct order to properly remove a Widget from a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.

  1. Validate: Make sure this Panel is actually the parent of the child Widget; return false if it is not.
  2. Orphan: Call {@link #orphan(Widget)} first while the child Widget is still attached.
  3. Physical Detach: Adjust the DOM to account for the removal of the child Widget. The Widget's Element must be physically removed from the DOM.
  4. Logical Detach: Update the Panel's state variables to reflect the removal of the child Widget. Example: the Widget is removed from the Panel's {@link WidgetCollection}.

@param child the widget to be removed @return <code>true</code> if the child was present

docs inherited from Panel
bool remove(Widget w) {
 return _decPanel.remove(w);
}

void removeAutoHidePartner(Element partner) #

inherited from PopupPanel

Remove an autoHide partner.

@param partner the auto hide partner to remove

void removeAutoHidePartner(dart_html.Element partner) {
 assert (partner != null); // : "partner cannot be null";
 if (autoHidePartners != null) {
   //autoHidePartners.remove(partner);
   partner.remove();
 }
}

void removeFromParent() #

inherited from Widget

Removes this widget from its parent widget, if one exists.

If it has no parent, this method does nothing. If it is a "root" widget (meaning it's been added to the detach list via {@link RootPanel#detachOnWindowClose(Widget)}), it will be removed from the detached immediately. This makes it possible for Composites and Panels to adopt root widgets.

@throws IllegalStateException if this widget's parent does not support

      removal (e.g. {@link Composite})
void removeFromParent() {
 if (_parent == null) {
   // If the widget had no parent, check to see if it was in the detach list
   // and remove it if necessary.
   if (RootPanel.isInDetachList(this)) {
     RootPanel.detachNow(this);
   }
 } else if (_parent is HasWidgets) {
   (_parent as HasWidgets).remove(this);
 } else if (_parent != null) {
   throw new Exception("This widget's parent does not implement HasWidgets");
 }
}

bool removeIsWidget(IsWidget child) #

inherited from Panel
bool removeIsWidget(IsWidget child) {
 return remove(Widget.asWidgetOrNull(child));
}

void removeStyleDependentName(String styleSuffix) #

inherited from UiObject

Removes a dependent style name by specifying the style name's suffix.

@param styleSuffix the suffix of the dependent style to be removed @see #setStylePrimaryName(Element, String) @see #addStyleDependentName(String) @see #setStyleDependentName(String, boolean)

void removeStyleDependentName(String styleSuffix) {
 setStyleDependentName(styleSuffix, false);
}

void removeStyleName(String style) #

inherited from UiObject

Removes a style name. This method is typically used to remove secondary style names, but it can be used to remove primary stylenames as well. That use is not recommended.

@param style the secondary style name to be removed @see #addStyleName(String) @see #setStyleName(String, boolean)

void removeStyleName(String style) {
 setStyleName(style, false);
}

void replaceElement(Element elem) #

inherited from Widget

Replaces this object's browser element.

This method exists only to support a specific use-case in Image, and should not be used by other classes.

@param elem the object's new element

void replaceElement(dart_html.Element elem) {
 if (isAttached()) {
   // Remove old event listener to avoid leaking. onDetach will not do this
   // for us, because it is only called when the widget itself is detached
   // from the document.
   Dom.setEventListener(getElement(), null);
 }

 super.replaceElement(elem);

 if (isAttached()) {
   // Hook the event listener back up on the new element. onAttach will not
   // do this for us, because it is only called when the widget itself is
   // attached to the document.
   Dom.setEventListener(getElement(), this);
 }
}

void setAnimation(ResizeAnimation animation) #

inherited from PopupPanel

Sets the animation used to animate this popup. Used by gwt-incubator to allow DropDownPanel to override the default popup animation. Not protected because the exact API may change in gwt 1.6.

@param animation the animation to use for this popup

void setAnimation(ResizeAnimation animation) {
 resizeAnimation = animation;
}

void setAnimationEnabled(bool enable) #

inherited from PopupPanel

Enable or disable animations.

@param enable true to enable, false to disable

docs inherited from HasAnimation
void setAnimationEnabled(bool enable) {
 _isAnimationEnabled = enable;
}

void setAnimationType(AnimationType type) #

inherited from PopupPanel

Enable or disable animation of the {@link PopupPanel}.

@param type the type of animation to use

void setAnimationType(AnimationType type) {
 animType = type;
}

void setAutoHideEnabled(bool autoHide) #

inherited from PopupPanel

Enable or disable the autoHide feature. When enabled, the popup will be automatically hidden when the user clicks outside of it.

@param autoHide true to enable autoHide, false to disable

void setAutoHideEnabled(bool autoHide) {
 this.autoHide = autoHide;
}

void setAutoHideOnHistoryEventsEnabled(bool enabled) #

inherited from PopupPanel

Enable or disable autoHide on history change events. When enabled, the popup will be automatically hidden when the history token changes, such as when the user presses the browser's back button. Disabled by default.

@param enabled true to enable, false to disable

void setAutoHideOnHistoryEventsEnabled(bool enabled) {
 this.autoHideOnHistoryEvents = enabled;
}

void setElement(Element elem) #

inherited from UiObject

Sets this object's browser element. UIObject subclasses must call this method before attempting to call any other methods, and it may only be called once.

@param elem the object's element

void setElement(dart_html.Element elem) {
 assert (_element == null);
 this._element = elem;
}

void setGlassEnabled(bool enabled) #

inherited from PopupPanel

When enabled, the background will be blocked with a semi-transparent pane the next time it is shown. If the PopupPanel is already visible, the glass will not be displayed until it is hidden and shown again.

@param enabled true to enable, false to disable

void setGlassEnabled(bool enabled) {
 this._isGlassEnabled = enabled;
 if (enabled && glass == null) {
   glass = new dart_html.DivElement();
   glass.className = glassStyleName;

   glass.style.position = Position.ABSOLUTE.value;
   glass.style.left = "0" + Unit.PX.value;
   glass.style.top = "0" + Unit.PX.value;
 }
}

void setGlassStyleName(String glassStyleName) #

inherited from PopupPanel

Sets the style name to be used on the glass element. By default, this is "gwt-PopupPanelGlass".

@param glassStyleName the glass element's style name

void setGlassStyleName(String glassStyleName) {
 this.glassStyleName = glassStyleName;
 if (glass != null) {
   glass.className = glassStyleName;
 }
}

void setHeight(String height) #

inherited from PopupPanel

Sets the height of the panel's child widget. If the panel's child widget has not been set, the height passed in will be cached and used to set the height immediately after the child widget is set.

Note that subclasses may have a different behavior. A subclass may decide not to change the height of the child widget. It may instead decide to change the height of an internal panel widget, which contains the child widget.

@param height the object's new height, in CSS units (e.g. "10px", "1em")

void setHeight(String height) {
 desiredHeight = height;
 maybeUpdateSize();
 // If the user cleared the size, revert to not trying to control children.
 if (height.length == 0) {
   desiredHeight = null;
 }
}

void setHtml(SafeHtml html) #

Sets the html string inside the caption by calling its {@link #setHtml(SafeHtml)} method.

Use {@link #setWidget(Widget)} to set the contents inside the {@link DialogBox}.

@param html the object's new Html

void setHtml(SafeHtml html) {
 caption.html = html.toString();
}

void setLayoutData(Object value) #

inherited from Widget

Sets the panel-defined layout data associated with this widget. Only the panel that currently contains a widget should ever set this value. It serves as a place to store layout bookkeeping data associated with a widget.

@param layoutData the widget's layout data

void setLayoutData(Object value) {
 this._layoutData = value;
}

void setModal(bool modal) #

inherited from PopupPanel

When the popup is modal, keyboard or mouse events that do not target the PopupPanel or its children will be ignored.

@param modal true to make the popup modal

void setModal(bool modal) {
 this.modal = modal;
}

void setParent(Widget parent) #

inherited from Widget

Sets this widget's parent. This method should only be called by {@link Panel} and {@link Composite}.

@param parent the widget's new parent @throws IllegalStateException if <code>parent</code> is non-null and the

      widget already has a parent
void setParent(Widget parent) {
 Widget oldParent = this._parent;
 if (parent == null) {
   try {
     if (oldParent != null && oldParent.isAttached()) {
       onDetach();
       assert (!isAttached()); // : "Failure of " + this.getClass().getName() + " to call super.onDetach()";
     }
   } finally {
     // Put this in a finally in case onDetach throws an exception.
     this._parent = null;
   }
 } else {
   if (oldParent != null) {
     throw new Exception("Cannot set a new parent without first clearing the old parent");
   }
   this._parent = parent;
   if (parent.isAttached()) {
     onAttach();
     assert (isAttached()); // : "Failure of " + this.getClass().getName() + " to call super.onAttach()";
   }
 }
}

void setPixelSize(int width, int height) #

inherited from UiObject

Sets the object's size, in pixels, not including decorations such as border, margin, and padding.

@param width the object's new width, in pixels @param height the object's new height, in pixels

void setPixelSize(int width, int height) {
 if (width >= 0) {
   setWidth(width.toString() + "px");
 }
 if (height >= 0) {
   setHeight(height.toString() + "px");
 }
}

void setPopupPosition(int left, int top) #

inherited from PopupPanel

Sets the popup's position relative to the browser's client area. The popup's position may be set before calling {@link #show()}.

@param left the left position, in pixels @param top the top position, in pixels

void setPopupPosition(int left, int top) {
 // Save the position of the popup
 leftPosition = left;
 topPosition = top;

 // Account for the difference between absolute position and the
 // body's positioning context.
 left -= dart_html.document.body.offset.left;
 top -= dart_html.document.body.offset.top;

 // Set the popup's position manually, allowing setPopupPosition() to be
 // called before show() is called (so a popup can be positioned without it
 // 'jumping' on the screen).
 dart_html.Element elem = getElement();
 elem.style.left = left.toString() + Unit.PX.value;
 elem.style.top = top.toString() + Unit.PX.value;
}

void setPopupPositionAndShow(PopupPanelPositionCallback callback) #

inherited from PopupPanel

Sets the popup's position using a {@link PositionCallback}, and shows the popup. The callback allows positioning to be performed based on the offsetWidth and offsetHeight of the popup, which are normally not available until the popup is showing. By positioning the popup before it is shown, the the popup will not jump from its original position to the new position.

@param callback the callback to set the position of the popup @see PositionCallback#setPosition(int offsetWidth, int offsetHeight)

void setPopupPositionAndShow(PopupPanelPositionCallback callback) {
 visible = false;
 show();
 callback.setPosition(getOffsetWidth(), getOffsetHeight());
 visible = true;
}

void setPreviewingAllNativeEvents(bool previewAllNativeEvents) #

inherited from PopupPanel

When enabled, the popup will preview all events, even if another popup was opened after this one.

If autoHide is enabled, enabling this feature will cause the popup to autoHide even if another non-modal popup was shown after it. If this feature is disabled, the popup will only autoHide if it was the last popup opened.

@param previewAllNativeEvents true to enable, false to disable

void setPreviewingAllNativeEvents(bool previewAllNativeEvents) {
 this.previewAllNativeEvents = previewAllNativeEvents;
}

void setSize(String width, String height) #

inherited from UiObject

Sets the object's size. This size does not include decorations such as border, margin, and padding.

@param width the object's new width, in CSS units (e.g. "10px", "1em") @param height the object's new height, in CSS units (e.g. "10px", "1em")

void setSize(String width, String height) {
 setWidth(width);
 setHeight(height);
}

void setStyleDependentName(String styleSuffix, bool add) #

inherited from UiObject

Adds or removes a dependent style name by specifying the style name's suffix. The actual form of the style name that is added is:

getStylePrimaryName() + '-' + styleSuffix

@param styleSuffix the suffix of the dependent style to be added or removed @param add <code>true</code> to add the given style, <code>false</code> to

     remove it

@see #setStylePrimaryName(Element, String) @see #addStyleDependentName(String) @see #setStyleName(String, boolean) @see #removeStyleDependentName(String)

void setStyleDependentName(String styleSuffix, bool add) {
 setStyleName(getStylePrimaryName() + '-' + styleSuffix, add);
}

void setStyleName(String style, bool add) #

inherited from UiObject

Adds or removes a style name. This method is typically used to remove secondary style names, but it can be used to remove primary stylenames as well. That use is not recommended.

@param style the style name to be added or removed @param add <code>true</code> to add the given style, <code>false</code> to

     remove it

@see #addStyleName(String) @see #removeStyleName(String)

void setStyleName(String style, bool add) {
 manageElementStyleName(getStyleElement(), style, add);
}

void setStylePrimaryName(String style) #

inherited from UiObject

Sets the object's primary style name and updates all dependent style names.

@param style the new primary style name @see #addStyleName(String) @see #removeStyleName(String)

void setStylePrimaryName(String style) {
 setElementStylePrimaryName(getStyleElement(), style);
}

void setTitle(String title) #

inherited from PopupPanel
void setTitle(String title) {
 dart_html.Element containerElement = getContainerElement();
 if (title == null || title.length == 0) {
   containerElement.attributes.remove("title");
 } else {
   containerElement.title = title;
 }
}

void setWidget(Widget w) #

inherited from DecoratedPopupPanel

Sets this panel's widget. Any existing child widget will be removed.

@param w the panel's new widget, or <code>null</code> to clear the panel

docs inherited from SimplePanel
void setWidget(Widget w) {
 _decPanel.setWidget(w);
 maybeUpdateSize();
}

void setWidgetIsWidget(IsWidget w) #

inherited from SimplePanel

Set the only widget of the receiver, replacing the previous widget if there was one.

@param w the widget, or <code>null</code> to remove the widget

@see SimplePanel

void setWidgetIsWidget(IsWidget w) {
 setWidget(Widget.asWidgetOrNull(w));
}

void setWidth(String width) #

inherited from PopupPanel

Sets the width of the panel's child widget. If the panel's child widget has not been set, the width passed in will be cached and used to set the width immediately after the child widget is set.

Note that subclasses may have a different behavior. A subclass may decide not to change the width of the child widget. It may instead decide to change the width of an internal panel widget, which contains the child widget.

@param width the object's new width, in CSS units (e.g. "10px", "1em")

void setWidth(String width) {
 desiredWidth = width;
 maybeUpdateSize();
 // If the user cleared the size, revert to not trying to control children.
 if (width.length == 0) {
   desiredWidth = null;
 }
}

void show() #

Shows the popup and attach it to the page. It must have a child widget before this method is called.

docs inherited from PopupPanel
void show() {
 if (resizeHandlerRegistration == null) {
//      resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {
//        void onResize(ResizeEvent event) {
//          windowWidth = event.getWidth();
//        }
//      });
 }
 super.show();
}

void showRelativeTo(UiObject target) #

inherited from PopupPanel

Normally, the popup is positioned directly below the relative target, with its left edge aligned with the left edge of the target. Depending on the width and height of the popup and the distance from the target to the bottom and right edges of the window, the popup may be displayed directly above the target, and/or its right edge may be aligned with the right edge of the target.

@param target the target to show the popup below

void showRelativeTo(UiObject target) {
 // Set the position of the popup right before it is shown.
 setPopupPositionAndShow(new ShowPositionCallback(this, target));
}

void sinkBitlessEvent(String eventTypeName) #

inherited from UiObject

Sinks a named event. Note that only {@link Widget widgets} may actually receive events, but can receive events from all objects contained within them.

@param eventTypeName name of the event to sink on this element @see com.google.gwt.user.client.Event

void sinkBitlessEvent(String eventTypeName) {
 Dom.sinkBitlessEvent(getElement(), eventTypeName);
}

void sinkEvents(int eventBitsToAdd) #

inherited from Widget

Overridden to defer the call to super.sinkEvents until the first time this widget is attached to the dom, as a performance enhancement. Subclasses wishing to customize sinkEvents can preserve this deferred sink behavior by putting their implementation behind a check of <code>isOrWasAttached()</code>:

{@literal @}Override
public void sinkEvents(int eventBitsToAdd) {
  if (isOrWasAttached()) {
    /{@literal *} customized sink code goes here {@literal *}/
  } else {
    super.sinkEvents(eventBitsToAdd);
 }
} 
void sinkEvents(int eventBitsToAdd) {
 if (isOrWasAttached()) {
   super.sinkEvents(eventsToSink);
 } else {
   eventsToSink |= eventBitsToAdd;
 }
}

String toString() #

inherited from UiObject

This method is overridden so that any object can be viewed in the debugger as an HTML snippet.

@return a string representation of the object

String toString() {
 if (_element == null) {
   return "(null handle)";
 }
 return getElement().toString();
}

void unsinkEvents(int eventBitsToRemove) #

inherited from UiObject

Removes a set of events from this object's event list.

@param eventBitsToRemove a bitfield representing the set of events to be

     removed from this element's event set

@see #sinkEvents @see com.google.gwt.user.client.Event

void unsinkEvents(int eventBitsToRemove) {
 Dom.sinkEvents(getElement(), Dom.getEventsSunk(getElement()) & (~eventBitsToRemove));
}

void updateHandlers() #

inherited from PopupPanel

Register or unregister the handlers used by {@link PopupPanel}.

void updateHandlers() {
 // Remove any existing handlers.
 if (nativePreviewHandlerRegistration != null) {
   nativePreviewHandlerRegistration.removeHandler();
   nativePreviewHandlerRegistration = null;
 }
 if (historyHandlerRegistration != null) {
   historyHandlerRegistration.removeHandler();
   historyHandlerRegistration = null;
 }

 // Create handlers if showing.
 if (showing) {
   nativePreviewHandlerRegistration = IEvent.addNativePreviewHandler(new NativePreviewHandlerAdapter((NativePreviewEvent event) {
     previewNativeEvent(event);
   }));
   historyHandlerRegistration = History.addValueChangeHandler(new HistoryValueChangeHandler(this));
 }
}