Link Search Menu Expand Document

DisplayObject.PopupMenu Method

Explanation Display a pop-up menu.

From Ver.5.0.0, it is possible to specify the menu by XML structure.
This removes the hierarchy restrictions and allows you to assign any ID.

Call format var id = obj.PopupMenu( menu1 [, menu2 [, menu3 … ] ] )
or
var id = obj.PopupMenu( menudef )
Return value The ID number automatically assigned to the menu choices is returned.

The first element of the menu is 1 for the ID . In the hierarchical menu, "value of upper element *100 + n " is the ID number of the submenu.
If no menu is selected, 0 is returned.
Arguments String menu Specify the menu choices as a character string.
If "-" is specified, the separator will be displayed.
A check mark is displayed by adding "*" to the first character .
If "~" is added to the first character, it will be invalid and cannot be selected.
If you specify an object that has child objects at the bottom, a hierarchical submenu is displayed. You can specify up to 4 levels of submenus.
If you specify an array, the array elements are expanded as menu items.
XmlDocument menudef Specifies the XmlDocumentobject in the menu definition.
XmlDocument whose XmlDOMImplementation.Unicode cannot be specified.

Added since Ver.5.0.0

Not supported in Mobile, AI

Exception None
Example of use Example 1) Specification by character string
var m1 = new String("menu1");  /*id=1*/
var m2 = new String("menu2");  /*id=2*/
var m3 = new String("-");
var m4 = new String("menu3");  /*id=4*/

var s1 = new String("*sub-menu1");  /* id=201 */
var s2 = new String("sub-menu2");   /* id=202 */
var s3 = new String("~sub-menu3");  /* id=203 */
m2.Append(s1);
m2.Append(s2);
m2.Append(s3);

var id = PopupMenu(m1, m2, m3, m4);
    
Example 2) XML specification
var x = new XmlDocument ();
x << xml <<-  
< ? xml version = "1.0" encoding = "SHIFT_JIS"? >
< menudefine>
    < menuitem id = "1" title = "menu1" />
    < menuitem id = "2" title = "menu2" checked = "true" />
    
    < menuitem id = "3" title = "menu3">
        < menuitem id = "11" title = "menu11" />
        < menuitem id = "12" title = "menu12" grayed = "true" />
        
        < menuitem id = "13" title = "menu13" checked = "true">
            < menuitem id = "21" title = "menu21" />
            < menuitem id = "22" title = "menu22" />
        </ menuitem>
    </ menuitem>
</ menudefine> 
->>;
var id = PopupMenu (x);
Related item Append method
XmlDocument class