Is there any reason you can't use the workaround they suggest in Jira?

Main Application:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
creationComplete="init()" xmlns:custom="*">
     <custom:myTextArea/>
</mx:Application>


myTextArea.as:
package
{
     import flash.events.ContextMenuEvent;
     import flash.text.TextField;
     import flash.ui.ContextMenu;
     import flash.ui.ContextMenuItem;
     import mx.controls.Alert;
     import mx.controls.TextArea;

     public class myTextArea extends TextArea
     {
         private var cm:ContextMenu;
         private var cmi:ContextMenuItem;

         public function myTextArea()
         {
             super();
             callLater(addCTMenu);
         }

         private function addCTMenu():void
         {
             cmi = new ContextMenuItem("View item...", true);
             cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
contextMenuItem_menuItemSelect);
             cm = new ContextMenu();
             cm.hideBuiltInItems();
             cm.customItems = [cmi];
             (textField as TextField).contextMenu = cm;
         }

         private function
contextMenuItem_menuItemSelect(evt:ContextMenuEvent):void
         {
             Alert.show("You just used a custom context menu on a
TextArea.");
         }
     }
}

NB: The reason I used callLater was that the textField was not
instanciated when the textArea was first created.


HTH.


Steve


--- In [email protected], "lehaianh1986" <lehaianh1...@...>
wrote:
>
> Thank kenneth. I want to add context menu in text area. Here is the
code
> <?xml version="1.0" encoding="utf-8"?>
> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml";
creationComplete="init()" >
>
>     <mx:Script>
>         <![CDATA[
>             import mx.controls.Alert;
>
>             [Bindable]
>             private var cm:ContextMenu;
>
>             private var alert:Alert;
>
>             private function init():void {
>                 var cmi:ContextMenuItem = new ContextMenuItem("View
item...", true);
>                
cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
contextMenuItem_menuItemSelect);
>
>                 cm = new ContextMenu();
>                 cm.hideBuiltInItems();
>                 cm.customItems = [cmi];
>
>             }
>
>             private function
contextMenuItem_menuItemSelect(evt:ContextMenuEvent):void {
>                 alert = Alert.show("You just used a custom context
menu on a TextArea.");
>             }
>         ]]>
>     </mx:Script>
>
>     <mx:TextArea contextMenu="{cm}" />
>
> </mx:WindowedApplication>
>
> I search and see in http://bugs.adobe.com/jira/browse/SDK-17684
>
> seem the bug is not fixed :(
>
> I don't know how to correct it. Can anyone help me!!!
>
> --- In [email protected], "Kenneth Sutherland"
kenneth.sutherland@ wrote:
> >
> > Try something like
> >
> > <mx:Canvas
> >
> >           contextMenu="{getyourMenu()}"
> >
> >
> >
> > />
> >
> >
> >
> > private function getyourMenu () : ContextMenu {
> >
> > var paste:ContextMenuItem = new ContextMenuItem("paste");
> >
> > paste.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
pasteHandler);
> >
> >
> >
> > var cm:ContextMenu = new ContextMenu();
> >
> >                              cm.hideBuiltInItems();
> >
> >                              cm.customItems.push(paste);
> >
> > return cm;
> >
> > }
>

Reply via email to