Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu construction with xml data #815

Closed
nihavend opened this issue Apr 28, 2020 · 3 comments
Closed

Menu construction with xml data #815

nihavend opened this issue Apr 28, 2020 · 3 comments
Assignees

Comments

@nihavend
Copy link
Contributor

nihavend commented Apr 28, 2020

Here is the expected view when click on the button :

image

live test click

Here is the test case :


<?xml version="1.0" encoding="latin5" ?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.apache.org/royale/spark"
			   xmlns:mx="library://ns.apache.org/royale/mx"
			   height="288" width="179"
			   >

	<fx:Script>
		<![CDATA[
			import mx.events.MenuEvent;
			import mx.controls.Menu;
			
			private function createAndShow():void {
				var myMenu:Menu = Menu.createMenu(null, filterMenuData, false);
				myMenu.id = "filterMenu"
				myMenu.labelField="@label";
				myMenu.addEventListener(MenuEvent.ITEM_CLICK, filterMenu_itemClickHandler);
				myMenu.show(statuFilterButton.localToGlobal(new Point(0,0)).x + 50, statuFilterButton.localToGlobal(new Point(0,0)).y + 25);
			}

			protected function filterMenu_itemClickHandler(event:MenuEvent):void {
				// to be implemented
				trace("Label of the menu item : " + event.label);
			}
				
		]]>
	</fx:Script>
	
	<fx:Declarations>
		<fx:XML format="e4x" id="filterMenuData">
			<menuitem label="Status Filter" id="statusFilter">
				<menuitem label="List All"/>			
				<menuitem label="Ready"/>
				<menuitem label="Waiting"/>
				<menuitem label="Working"/>
				<menuitem label="Successful"/>
				<menuitem label="Failed"/>
				<menuitem label="Time-out"/>
				<menuitem label="Skipped"/>
				<menuitem label="Stopped}"/>
				<menuitem label="Paused"/>
				<menuitem label="Disabled"/>
			</menuitem>
		</fx:XML>
	</fx:Declarations>

	<mx:Button id="statuFilterButton" label="Select Filter" click="createAndShow();"/>
	
</s:Application>

@aharui aharui self-assigned this May 11, 2020
@aharui
Copy link
Contributor

aharui commented May 12, 2020

The Menu.show call will have an additional first parameter.

myMenu.show(null, statuFilterButton.localToGlobal(new Point(0,0)).x + 50, statuFilterButton.localToGlobal(new Point(0,0)).y + 25);

@aharui aharui closed this as completed in b98a1a5 May 13, 2020
@nihavend
Copy link
Contributor Author

I confirm that menu is displayed @aharui

But with two problems (needs to be reopened)

  1. menu displayed but but not as expected
  2. onClick handler is not functioning

live test click

image

Displays the root element of the xml as menu and the rest as submenus which is not I needed. You can see the one in flex above.

@yishayw
Copy link
Contributor

yishayw commented Jan 19, 2022

The Menu.show call will have an additional first parameter.

myMenu.show(null, statuFilterButton.localToGlobal(new Point(0,0)).x + 50, statuFilterButton.localToGlobal(new Point(0,0)).y + 25);

@aharui , I know it's been a while, but can you explain why the extra param is necessary. There is code that only runs when parent is null without which the menu does not display properly in our app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants