Prev | Current Page 911 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Under such circumstances, however, the methods of the Item class will no longer apply to
the item.
Appending Submenus
The addItem method of the Menu class accepts objects that implement the IMenu interface. This means
that both objects of the Item class and those of the Submenu class can be added to an object of type Menu .
A submenu is essentially an object consisting of a child menu object and a reference string. The submenu
object then acts as a proxy for the child menu object, so it can be safely added to a parent menu. You
create an object of type Submenu by passing both menu and reference string to its constructor, like this:
var sub = new Submenu( ???my menu???, menu );
In this instance, the sub variable can then be used in the same way as an Item object, where the
reference string is used as the items label.
Menu Events
Objects derived from the Item class support the event onClick . This event will usually need to be
added to each item object individually as the event function accepts no parameters, so it is not often
possible to obtain which menu item was selected.


Pages:
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923