Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Re: MenuBar: Detecting submenus and getting events from them.

Expand Messages
  • Todd Kloots
    Craig - You can check if a given menu item has a submenu via its submenu configuration property. Some pseudo code: var aItems = oMenu.getItems(); for (...)
    Message 1 of 4 , Apr 27, 2007
    • 0 Attachment
      Craig -

      You can check if a given menu item has a submenu via its "submenu"
      configuration property. Some pseudo code:

      var aItems = oMenu.getItems();

      for (...) {

      if(aItem[i].cfg.getProperty("submenu")) {

      // has submenu

      }

      }

      - Todd

      craig39999 wrote:
      > Josh, did you ever find a solution to this problem? I am trying to
      > do the same thing, run thru my list of menu items and determine which
      > ones have submenus so I can add click event handlers to them.
      >
      > Thanks,
      >
      > Craig.
      >
      > --- In ydn-javascript@yahoogroups.com, "Josh Santangelo" <joshs@...>
      > wrote:
      >
      >> Just replying to myself here, since I haven't found a solution --
      >> maybe the earlier message got lost being sent out late on a Fri
      >>
      > night.
      >
      >> Would appreciate any tips.
      >>
      >> thanks,
      >> -josh
      >>
      >> --- In ydn-javascript@yahoogroups.com, "Josh Santangelo" <joshs@>
      >> wrote:
      >>
      >>> I currently have a MenuBar widget created from markup. It has six
      >>> MenuItems, each with a submenu.
      >>>
      >>> I want to listen for click events on the sub menu. How do I do
      >>>
      > that? I
      >
      >>> currently have it working like so:
      >>>
      >>> var i=0;
      >>> var menuItem = this.menuBar.getItem(i);
      >>> while(menuItem)
      >>> {
      >>> if(menuItem._oSubmenu)
      >>> {
      >>> menuItem._oSubmenu.clickEvent.subscribe(this.onClickMenuItem,
      >>>
      > this);
      >
      >>> menuItem._oSubmenu.beforeShowEvent.subscribe
      >>>
      > (this.onBeforeShowMenu,
      >
      >>> this);
      >>> }
      >>>
      >>> i++;
      >>> menuItem = this.menuBar.getItem(i);
      >>> }
      >>>
      >>> this.onClickMenuItem does fire when a submenuitem is clicked, but
      >>>
      > I'm
      >
      >>> pretty sure I'm not supposed to be accessing it with ._oSubmenu
      >>>
      > like
      >
      >>> that. MenuItem doesn't seem to have a getSubmenu or similar
      >>>
      > method,
      >
      >>> though.
      >>>
      >>> Another question is related to the above code as well. I'm trying
      >>>
      > to
      >
      >>> listen to the beforeShowEvent of the submenu because I need to
      >>>
      > make
      >
      >>> sure its z-index is on top of other elements on this page (whose
      >>> z-indexes change over the course of time). I can trap the
      >>> beforeShowEvent object, but the only arguments passed to it are
      >>>
      > the
      >
      >>> top MenuBar widget, so I have no way of knowing which submenu is
      >>>
      >> showing.
      >>
      >>> thanks,
      >>> -josh
      >>>
      >>>
      >
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.