-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Building "nested" ColumnMenu's #151
Comments
@NuSkooler I ran into a similar issue 2 weeks ago with blink, so I added a The EDIT: the name of the event is |
@NuSkooler Added |
@NuSkooler By nested menu, do you mean a sub-menu that pop on the right? Or do you mean a menu that replace the current one? |
@cronvel What I'm attempting to build is a menu that has multiple sub levels, but I'm very constrained for space so I'd like to draw them without indentation/etc. Example, assuming "Item 2" is selected:
The menu becomes:
Update: let mainMenu;
let subMenu;
mainMenu = new TermKit.ColumnMenu({
// ...
items : [
{
content : 'Menu Item',
value : () => {
mainMenu.hide();
document.giveFocusTo(subMenu);
subMenu.show();
}
}
]
});
mainMenu.on('blinked', handler => handler());
subMenu = new TermKit.ColumnMenu({
// ...
items : [
{
content : 'Sub Menu Item',
value : () => {
subMenu.hide();
document.giveFocusTo(mainMenu);
mainMenu.show();
}
}
]
});
subMenu.on('blinked', handler=> handler()); |
@NuSkooler I have a very rough support for submenu, look at the file |
@NuSkooler The submenu features is refined and published as v1.49.1. |
@cronvel Thank you so much for implementing this - I'm replacing my custom implementation with this now and so far it's working quite well. One issue: sub menu items do not appear to generate 'focus' events. Seems |
This almost works, but when leaving a sub, BaseMenu.prototype.onButtonFocus = function( focus , type , button ) {
switch ( button.internalRole ) {
case 'previousPage' :
case 'nextPage' :
break ;
default :
if ( focus && this.hasSubmenu && button.def.items && this.submenuOptions.openOn === 'parentFocus' ) {
this.openSubmenu( button.value , button ) ;
}
this.emit( 'itemFocus' , button.value , focus , button ) ;
if (this.isSubmenu && this.parent) {
let parent = this.parent;
while (parent.isSubmenu) {
parent = parent.parent;
}
parent.emit( 'itemFocus' , button.value , focus , button ) ;
}
}
} ; |
@NuSkooler You want |
@cronvel I want to be careful about saying "parent" here, but rather the "owning" menu (since there are in fact N arbitrary parents in nested sub menus). const menu = new TermKit.ColumnMenu({
// ...
items: [
// ...
items : [
// ...
items : [
content : "Foo",
value : 'foo',
]
]
]
});
menu.on('itemFocus', (focus, value) => {
// focus of "Foo" should fire here.
}); |
@NuSkooler Done and published as v2.0.2. |
@cronvel Thank you, this is working wonderfully! |
I'm attempting to build "nested"
ColumMenu
's. What I mean by this is for example if a user selects a top level menu item "A", the menu is replaced with "B". If they choose "C" from B, they get another menu. This can all be unwound e.g. by pressing ESC.This seems very similar to #150 - Update A ColumnMenu's Items.
Currently I'm attempting to do this via multiple menus with the same dimensions and coordinates. E.g.:
This is of course a hack. Some things I think would help is
element.show()
/element.hide()
.Additionally I'm running into a issue with 'blink()'. Since this happens with a timer, "B" is drawn then "A"'s blink loop messes with it. A couple thoughts:
Finally, is a nested menu system like this anywhere on the roadmap? If a single element could allow nesting and perhaps menu ident for nested items (I would use 0 indent in my case)? A x/y indent would allow for "tree" type views perhaps.
Any hints appreciated. I'd like to make myself more useful other than just asking stuff, but will need some hints on where you're taking things in order to do any coding.
The text was updated successfully, but these errors were encountered: