Context menu doesn't work in Flex 4 Applications
TroubleshootingSummary
The ContextMenuInputMode allows to define custom context menus. Under certain conditions it doesn't dispatch the correct events in Flex 4 applications with Spark components.
Description
Problem
If the GraphCanvasComponent
is inside a <s:Panel>
it doesn't open a custom context menu. As a consequence, the ContextMenuInputMode
doesn't dispatch the MENU_SELECT
event.
Cause
This is due to a bug in s:Panel
: https://bugs.adobe.com/jira/browse/SDK-26182.
Workaround
A workaround is provided in the above bug report:
- set mouseEnabled=true in Panel
- create a custom skin which inherits from
spark.skins.spark.PanelSkin
- set mouseEnabled=true in the created custom skin
Setting the mouseEnabled
property and the custom Skin can be easily achieved in mxml:
<s:Panel mouseEnabled="true" skinClass="demo.style.YPanelSkin">
Developers who define their panel in ActionScript have to remember that skinClass
is a style and not a property:
var panel:Panel = new Panel();
panel.mouseEnabled = true;
panel.setStyle("skinClass", YPanelSkin);
The custom skin itself does nothing else than setting the mouseEnabled property to true:
``` package demo.style { import spark.skins.spark.PanelSkin;public class YPanelSkin extends PanelSkin { override public function YPanelSkin() { super(); mouseEnabled = true; } } } ```
Resources
Categories this article belongs to:
yFiles FLEX > Displaying and Editing Graphs > User Interaction
Applies to:
yFiles FLEX: 1.5, 1.6, 1.7, 1.8
Keywords:
ContextMenuInputMode - context menu - Flex 4 - s:Panel - spark