Skip to content

addCustomControlMapping for opening subMenu ? #171

@vesper8

Description

@vesper8

I can set keyboard mapping for regular callables but I would like to use it to open a submenu.. any way to achieve that?

        $subMenu = function (CliMenuBuilder $b) {
            $b->setTitle('Behold the awesomeness')
                ->addItem('Print Hello', function () { echo 'Hello!'; });
        };

        $exit = function (CliMenu $menu) {
            $menu->close();
        };

        $menu = (new CliMenuBuilder)
        ->addSubMenu('[S]uper Sub Menu', $subMenu)
        ->build();

        $menu->addCustomControlMapping('x', $exit);
        $menu->addCustomControlMapping('s', $subMenu);

        $menu->open();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions