Skip to content

Commit

Permalink
New: DropDownMenu#setDropDownItem()
Browse files Browse the repository at this point in the history
  • Loading branch information
cronvel committed Feb 2, 2021
1 parent 7d656eb commit a69704d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

v1.46.1
-------

New: DropDownMenu#setDropDownItem()


v1.46.0
-------

Expand Down
12 changes: 12 additions & 0 deletions lib/document/DropDownMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ DropDownMenu.prototype.clearColumnMenu = function() {



DropDownMenu.prototype.setDropDownItem = function( topItemValue , dropDownItemValue , itemOptions ) {
var topItem = this.itemsDef.find( e => e.value === topItemValue ) ;
if ( ! topItem ) { return false ; }
var dropDownItem = topItem.items && topItem.items.find( e => e.value === dropDownItemValue ) ;
if ( ! dropDownItem ) { return false ; }
this.clearColumnMenu() ;
Object.assign( dropDownItem , itemOptions ) ;
return true ;
} ;



DropDownMenu.prototype.onClickOut = function( buttonValue , data , button ) {
this.clearColumnMenu() ;
} ;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "terminal-kit",
"version": "1.46.0",
"version": "1.46.1",
"description": "256 colors, keys and mouse, input field, progress bars, screen buffer (including 32-bit composition and image loading), text buffer, and many more... Whether you just need colors and styles, build a simple interactive command line tool or a complexe terminal app: this is the absolute terminal lib for Node.js!",
"main": "lib/termkit.js",
"directories": {
Expand Down
7 changes: 7 additions & 0 deletions sample/document/drop-down-menu-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ function onSubmit( buttonValue ) {
term.saveCursor() ;
term.moveTo.styleReset.eraseLine( 1 , 22 , 'Submitted: %s\n' , buttonValue ) ;
term.restoreCursor() ;

if ( buttonValue === 'decrunch' ) {
dropDownMenu.setDropDownItem( 'tools' , 'decrunch' , { content: 'Crunch' , value: 'crunch' } ) ;
}
else if ( buttonValue === 'crunch' ) {
dropDownMenu.setDropDownItem( 'tools' , 'crunch' , { content: 'Decrunch' , value: 'decrunch' } ) ;
}
}


Expand Down

0 comments on commit a69704d

Please sign in to comment.