Search code examples
apache-flexcontextmenutextinputflex-spark

Accessing the contextMenu of a spark TextInput component


How can I add custom context menu items to the context menu of a spark TextInput component? I am using Flex 4.5.1.

Assuming I have a spark TextInput called sparktext:

trace(sparktext.contextMenu) // returns null
trace(sparktext.textDisplay.contextMenu) // returns null

Since those returned null, I though I would just create a contextMenu using:

sparktext.contextMenu = new ContextMenu()
//add entries

Or

sparktext.textDisplay.contextMenu = new ContextMenu()
//add entries

Now a contextMenu is created. But the created context menu is a "flash" context menu, displaying items like "play", "zoom" and so on. I have lost entries for items like "copy", "paste" and so on.

I have tried creating a RichEditableText, and its contextMenu property actually contains a ContextMenu object. I am at lost as to why the RichEditableText object, which is stored in TextInput.textDisplay does not contain a ContextMenu object in its contextMenu property.

Can anyone shed some light on this and how I can ADD context menu items to the context menu of a TextInput?


Solution

  • Still couldn't work out why sparktext.textDisplay.contextMenu is NULL.

    But here's what I did:

    var testmenu:ContextMenu = new ContextMenu();
    testmenu.hideBuiltInItems();
    testmenu.clipboardMenu = true; //Use this to show the options such as copy, paste and so on.
    sparktext.textDisplay.contextMenu = testmenu;