Results 1 to 2 of 2

Thread: CustomEvent sent by Menu Item

  1. #1
    Ext User
    Join Date
    Mar 2007

    Default CustomEvent sent by Menu Item


    Subscribed a function to a menu item 'click' event which simply creates a custom event and fires it directly (see below):
    var newResourceEvent = new YAHOO.util.CustomEvent('new resource');
    var menuMessageEvent = new YAHOO.util.CustomEvent('menu message');
    function fireNewResourceEvents() {
      menuMessageEvent.fireDirect('another message to myself');
    the function above resides in a application-menubar.js file. And when I build my layout inside a application-layout.js file just after rendering I want to assign a listener to the status panel (i.e. 'south' region):
    function handleMenuMessage(message) {
    var statusPanel = getEl('south');
    statusPanel.addManagedListener('menu message', handleMenuMessage);

    the event gets fired by the clicking on the menu item but the "handleMenuMessage" function never reacts. Have I totally misunderstood the EventManager? Thought I could define an arbitary event anywhere and the type property (in this case 'menu message' or 'new resource') would uniquely identity the event to the listener (subscriber) on the Element object. Doesn't seem to be the case.

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    New York, NY


    That's not what it does. The EventManager just provides a normalized event object for events and some useful events such as onDocumentReady and onWindowResize.

    You can add events to the panels though as they extend Observable. You would do something like this:

    var foo = new YAHOO.ext.ContentPanel(...);
    // no spaces in event name['menuevent'] = new YAHOO.util.CustomEvent('menuevent');
    foo.on('menuevent', myFunction);

    To fire the event, you'd call:

    foo.fireEvent('menuevent', arg1, arg2, etc);

    or from inside the foo object:

    this.fireEvent('menuevent', arg1, arg2, etc);

Similar Threads

  1. Toolbar item enhancement. Item align:"right" confi
    By Animal in forum Ext 2.x: Help & Discussion
    Replies: 40
    Last Post: 8 Jan 2008, 6:28 PM
  2. Color Menu Item Bug
    By John Huang in forum Ext 1.x: Bugs
    Replies: 2
    Last Post: 2 Apr 2007, 6:29 AM
  3. How do you retrieve checked item in menu and submenu?
    By n01champion in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 22 Feb 2007, 7:35 AM
  4. About the implementation of DOWNLOADS menu item of yui-ext
    By codeexploiter in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 20 Feb 2007, 9:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts