Beispiel #1
0
  /**
   * Sets the active item. The component must be of type <code>Item</code> to be activated. All
   * other types are ignored.
   *
   * @param c the component to set active
   * @param autoExpand true to auto expand the item
   */
  public void setActiveItem(Component c, boolean autoExpand) {
    if (c == null) {
      deactiveActiveItem();
      return;
    }
    if (c instanceof Item) {
      Item item = (Item) c;
      if (item != activeItem) {
        deactiveActiveItem();

        this.activeItem = item;
        item.activate(autoExpand);
        item.el().scrollIntoView(ul.dom, false);
        focus();

        if (GXT.isFocusManagerEnabled()) {
          FocusFrame.get().frame(item);
          Accessibility.setState(getElement(), "aria-activedescendant", item.getId());
        }

      } else if (autoExpand) {
        item.expandMenu(autoExpand);
      }
    }
  }
Beispiel #2
0
 protected void onMouseOut(ComponentEvent ce) {
   EventTarget to = ce.getEvent().getRelatedEventTarget();
   if (activeItem != null
       && (to == null
           || (Element.is(to)
               && !DOM.isOrHasChild(activeItem.getElement(), (Element) Element.as(to))))
       && activeItem.shouldDeactivate(ce)) {
     deactiveActiveItem();
   }
 }
Beispiel #3
0
 /**
  * Removes a item from the menu.
  *
  * @param item the menu to remove
  */
 @Override
 public boolean remove(Component item) {
   if (activeItem == item) {
     deactiveActiveItem();
   }
   boolean success = super.remove(item);
   if (success && item instanceof Item) {
     ((Item) item).parentMenu = null;
   }
   return success;
 }
Beispiel #4
0
 @Override
 protected void onHide() {
   super.onHide();
   deactiveActiveItem();
 }