Can i use file menu.hx in folder containers/menu/..?

On the new-component-method… File menu.hx in folder containers/menu/…, Can i use it.? Thanks

Hi!

The menu system in new-component-method branch is currently work in progress, but it can be used. However, at the moment (and this will be changed shortly) you can only have top level menus, eg:

<menubar width="100%">
    <menu text="File">
        <menuitem text="Item 1" />
        <menu text="Sub Menu">
            <menuitem text="Item 1" />
            <menuitem text="Item 2" />
            <menuitem text="Item 3" />
            <menuseparator />
            <menucheckbox text="Item 4" />
            <menucheckbox text="Item 5" />
            <menucheckbox text="Item 6" />
            <menuseparator />
            <menuoptionbox text="Item 7" />
            <menuoptionbox text="Item 8" />
            <menuoptionbox text="Item 9" />
        </menu>
    </menu>
    <menu text="Edit">
        <menuitem text="Item 1" />
    </menu>
    <menu text="Help">
        <menuitem text="Item 1" />
    </menu>
</menubar>

image

So this means currently you have to use menubar to contain all your menus. Eventually this will be extended to standalone menus (for example), on right click.

Were you thinking about using with a menubar or, for example, with a right click?

Cheers,
Ian

it mean i can extend menu from haxe.ui.containers.menu.Menu ?
i usually extend like this …
image

You should be able to, its just a normal haxeui component. I mean, things like this should also work:

class MySpecialMenu extends Menu {
    public function new() {
        addComponent(new MenuItem()).text = "Item 1";
        addComponent(new MenuItem()).text = "Item 2";
        addComponent(new MenuItem()).text = "Item 3";
    }
}
<menubar width="100%">
    <myspecialmenu />
</menubar>

Note: If you want to use the class via xml in this way then you must also register it in a module.xml - but thats probably out of scope for this question.

Im not sure if that is exactly what you are asking? If not might need a few more details of exactly what it is you are trying to do.

Cheers,
Ian

1 Like

Thank you so much… i solved my problem,:+1:

Hi Ian,

Should the standalone right click work as of now ? I have seen boilerplate code for it and from my understanding of the event system the calls should be sent. But from what I have tried it doesn’t seem to work.

backend: haxeui-kha master branch

Here is my code setup:


@:build(haxe.ui.macros.ComponentMacros.build("../Assets/custom/editor-tab.xml"))
class EditorTab extends Component {

    public function new(){
        super();
        var t:TabView = this.findComponent(TabView);
        t.height = Screen.instance.height*0.95;
        this.tabs.width = Screen.instance.width*0.95;
    }
    @:bind(tabs,MouseEvent.RIGHT_CLICK)
    function onRightclickcall(e:MouseEvent) {
        var menu = new Menu();
        trace("was called");
    }
}

The xml for reference:

<?xml version="1.0" encoding="utf-8" ?>
<tabview id="tabs" >
    <box text="sub page 1">
        <button text="bob" />
    </box>
</tabview>

I thought i had answered this to be honest… I remember looking at kha and it seems right click isnt implemented there, but im not sure. Either way, ill make sure the menus can be opened as popups via right click on all backends (ill add examples to the component-examples/menus repo)

Cheers,
Ian