Hello, I started learning Haxe & HaxeUI a couple of weeks ago. I’m trying to port my little apps written in Python in Haxe but I’m experiencing some problems using the menu entries of the app menu. I’m writing an app using hxWidgets and everything works fine apart the menu management. In main-view.xml I put this portion of code:
<menubar id="mainMenu" width="100%" >
<menu id="menuFile" text="File" >
<menuitem id="menuRun" text="Run" />
<menuitem id="menuQuit" text="Quit" />
</menu>
</menubar>
Then I tried this piece of code found on this site, adding another check by myself:
var menuBars = this.findComponents(MenuBar);
trace("MenuBars:", menuBars.length);
for (m in menuBars) {
trace(" ---> " + m.id);
}
var menus = this.findComponents(Menu);
trace("Menus:", menus.length);
for (m in menus) {
trace(" ---> " + m.id);
}
var menuItems = this.findComponents(MenuItem);
trace("MenuItems:", menuItems.length);
for (m in menuItems) {
trace(" ---> " + m.id);
}
var menuRun = cast(findComponent("menuRun", MenuItem), MenuItem);
trace(menuRun.text);
This is the output:
src/MainView.hx:34: MenuBars:,1
src/MainView.hx:36: ---> mainMenu
src/MainView.hx:39: Menus:,1
src/MainView.hx:41: ---> menuFile
src/MainView.hx:44: MenuItems:,2
src/MainView.hx:46: ---> menuRun
src/MainView.hx:46: ---> menuQuit
src/MainView.hx:50: Run
It seems out of doubt that the menu items are seen. But from now on I don’t know how to bind a function to catch an event. Sincererly, I don’t know which event to catch, too, because the documentations seems to be a little incomplete, IMHO… I tried the two solutions below but I didn’t get anything:
menuRun.registerEvent(MenuEvent.MENU_SELECTED, function(me:MenuEvent) {
trace(me.menuItem.id);
});
menuRun.onChange = function(e) {
trace('hello');
}
Any suggestions? Thanks.