Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
MenuBar's itemClick event only for submenu items
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rene Rodriguez  
View profile  
 More options Dec 22 2008, 6:50 pm
From: "Rene Rodriguez" <gr8jedimas...@gmail.com>
Date: Mon, 22 Dec 2008 15:50:24 -0800
Local: Mon, Dec 22 2008 6:50 pm
Subject: MenuBar's itemClick event only for submenu items

In Flex 3, the MenuBar component does not support the itemClick event for
top-level menu items that do not have submenus.  The Language Reference
defines the itemClick event as "Dispatched when the user selects an item in
a pop-up submenu."

Is there a way to access the top-level menu items?

 Here's a sample code that illustrates.  This code is a modification from
Adobe(R) Flex™ 3 Language Reference on "MenuBar", where Menu3 is a top-level
menu item that does not have any submenu.

<?xml version="1.0"?>
<!-- Simple example to demonstrate the MenuBar control. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initCollections();" >

    <mx:Script>
        <![CDATA[

            import mx.events.MenuEvent;
            import mx.controls.Alert;
            import mx.collections.*;

            [Bindable]
            public var menuBarCollection:XMLListCollection;

            private var menubarXML:XMLList =
                <>
                    <menuitem label="Menu1" data="1">
                        <menuitem label="MenuItem 1-A" data="1A"/>
                        <menuitem label="MenuItem 1-B" data="1B"/>
                    </menuitem>
                    <menuitem label="Menu2" data="2">
                        <menuitem label="MenuItem 2-A" type="check"
data="2A"/>
                        <menuitem type="separator"/>
                        <menuitem label="MenuItem 2-B" >
                            <menuitem label="SubMenuItem 3-A" type="radio"
                                groupName="one" data="3A"/>
                            <menuitem label="SubMenuItem 3-B" type="radio"
                                groupName="one" data="3B"/>
                        </menuitem>
                    </menuitem>
                    <menuitem label="Menu3" data="3">
                    </menuitem>
                </>;

            // Event handler to initialize the MenuBar control.
            private function initCollections():void {
                menuBarCollection = new XMLListCollection(menubarXML);
            }

            // Event handler for the MenuBar control's itemClick event.
            private function menuHandler(event:MenuEvent):void  {
                    Alert.show("Label: " + event.item.@label + "\n" +
                        "Data: " + event.item.@data, "Clicked menu item");
            }
         ]]>
    </mx:Script>

    <mx:Panel title="MenuBar Control Example" height="75%" width="75%"
        paddingTop="10" paddingLeft="10">

        <mx:Label width="100%" color="blue"
           text="Select a menu item."/>

        <mx:MenuBar labelField="@label" itemClick="menuHandler(event);"
            dataProvider="{menuBarCollection}" />

    </mx:Panel>
</mx:Application>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
chuckb  
View profile  
 More options Dec 23 2008, 3:00 pm
From: chuckb <futr...@gmail.com>
Date: Tue, 23 Dec 2008 12:00:46 -0800 (PST)
Local: Tues, Dec 23 2008 3:00 pm
Subject: Re: MenuBar's itemClick event only for submenu items
Rene ---
The MenuBar parent is not considered an item, but you can add an event
handler to it with a couple of small changes to your sample code.

1. Add an initialization call for the application's creationComplete
event

2. The Script's initialization call, among other things, add a mouse
click listener to a MenuBar:

private function initListeners(): void {
  this.menuBar1.addEventListener(MouseEvent.CLICK,
this.menuBarHandler);

}

3. Also in the Script's menu bar handler, check to see how many items
(children) it has, and branch accordingly:

private function menuBarHandler(event:MouseEvent): void {
  if (this.menuBar1.menuBarItems.length > 0) {
    // redirect the event to the item handler, etc.
  }
  else {
    // stand-alone menu bar processing
  }

}

You may also want to remove the menu bar listener when menu items are
added to it, eliminating that call and its associated overhead. The
menu item listener then takes over.

chuckb

On Dec 22, 3:50 pm, "Rene Rodriguez" <gr8jedimas...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »