Example #1
0
  /**
   * Displays this menu at a specific xy position.
   *
   * @param x the x coordinate
   * @param y the y coordinate
   */
  public void showAt(int x, int y) {
    MenuEvent me = new MenuEvent(this);
    if (fireEvent(Events.BeforeShow, me)) {
      RootPanel.get().add(this);

      el().makePositionable(true);

      onShow();
      el().updateZIndex(0);

      showing = true;
      doAutoSize();

      if (constrainViewport) {
        Point p = el().adjustForConstraints(new Point(x, y));
        x = p.x;
        y = p.y;
      }
      setPagePosition(x + XDOM.getBodyScrollLeft(), y + XDOM.getBodyScrollTop());
      if (enableScrolling) {
        constrainScroll(y);
      }

      el().show();
      eventPreview.add();

      if (focusOnShow) {
        focus();
      }

      fireEvent(Events.Show, me);
    }
  }
Example #2
0
  /**
   * Displays this menu relative to another element.
   *
   * @param elem the element to align to
   * @param pos the {@link El#alignTo} anchor position to use in aligning to the element (defaults
   *     to defaultAlign)
   * @param offsets the menu align offsets
   */
  public void show(Element elem, String pos, int[] offsets) {
    MenuEvent me = new MenuEvent(this);
    if (fireEvent(Events.BeforeShow, me)) {
      RootPanel.get().add(this);

      el().makePositionable(true);

      onShow();
      el().updateZIndex(0);

      showing = true;
      doAutoSize();

      el().alignTo(elem, pos, offsets);

      if (enableScrolling) {
        constrainScroll(el().getY());
      }
      el().show();

      eventPreview.add();

      if (focusOnShow) {
        focus();
      }

      fireEvent(Events.Show, me);
    }
  }
 /** {@inheritDoc} */
 @Override
 protected void onFocus(ComponentEvent ce) {
   focusPreview.add();
 }
Example #4
0
 protected void onMouseOver(ComponentEvent ce) {
   if (!disabled && handleMouseEvents) {
     addStyleName(baseStyle + "-over");
   }
   preview.add();
 }
Example #5
0
  protected void afterShow() {
    hidden = false;

    // layout early to render window's content for size calcs
    if (!layoutExecuted || isLayoutNeeded()) {
      layout();
    }

    if (restorePos != null) {
      setPosition(restorePos.x, restorePos.y);
      if (restoreSize != null) {
        setSize(restoreSize.width, restoreSize.height);
      }
    }
    if (restoreWindowScrolling != null) {
      com.google.gwt.dom.client.Document.get().enableScrolling(false);
    }

    int h = getHeight();
    int w = getWidth();
    if (h < minHeight && w < minWidth) {
      setSize(minWidth, minHeight);
    } else if (h < minHeight) {
      setHeight(minHeight);
    } else if (w < minWidth) {
      setWidth(minWidth);
    }

    // not positioned, then center
    if (!positioned) {
      el().center(true);
    }

    el().updateZIndex(0);
    if (modal) {
      modalPreview =
          Event.addNativePreviewHandler(
              new NativePreviewHandler() {
                public void onPreviewNativeEvent(NativePreviewEvent event) {
                  if (Element.is(event.getNativeEvent().getEventTarget())) {
                    Element target = (Element) Element.as(event.getNativeEvent().getEventTarget());

                    String tag = target.getTagName();
                    // ignore html and body because of frames
                    if (!resizing
                        && !dragging
                        && !tag.equalsIgnoreCase("html")
                        && !tag.equalsIgnoreCase("body")
                        && event.getTypeInt() != Event.ONLOAD
                        && manager.getActive() == Window.this
                        && (modalPanel == null
                            || (modalPanel != null
                                && !modalPanel.getElement().isOrHasChild(target)))
                        && !Window.this.getElement().isOrHasChild(target)
                        && fly(target).findParent(".x-ignore", -1) == null) {
                      ArrayList<Component> col =
                          new ArrayList<Component>(ComponentManager.get().getAll());
                      for (Component c : col) {
                        if (c instanceof TriggerField<?>) {
                          triggerBlur((TriggerField<?>) c);
                        } else if (c instanceof Menu) {
                          ((Menu) c).hide(true);
                        }
                      }
                      Window.this.focus();
                    }
                  }
                }

                private native void triggerBlur(TriggerField<?> field) /*-{
    [email protected]::triggerBlur(Lcom/extjs/gxt/ui/client/event/ComponentEvent;)(null);
  }-*/;
              });
    }

    // missing cursor workaround
    if (GXT.isGecko) {
      El e = el().selectNode(".x-window-bwrap");
      if (e != null) {
        e.dom.getStyle().setProperty("overflow", "auto");
        e.dom.getStyle().setProperty("position", "static");
      }
    }

    eventPreview.add();

    if (maximized) {
      maximize();
    }
    removeStyleName(HideMode.VISIBILITY.value());

    if (GXT.isAriaEnabled()) {
      Accessibility.setState(getElement(), "aria-hidden", "false");
    }

    fireEvent(Events.Show, new WindowEvent(this));
    toFront();
  }