bugfix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-01-18 01:34:06 +03:00
parent b58b583995
commit 91dd994cf1
2 changed files with 36 additions and 31 deletions

View File

@ -1125,6 +1125,7 @@ var KeyboardActions = actions.Actions({
editKeyBinding: ['- Interface/Key mapping...', editKeyBinding: ['- Interface/Key mapping...',
widgets.makeUIDialog(function(mode, code){ widgets.makeUIDialog(function(mode, code){
var that = this var that = this
var abort = false
// list the keys (cache)... // list the keys (cache)...
var keys = that.keyboard.keys(code) var keys = that.keyboard.keys(code)
@ -1149,6 +1150,12 @@ var KeyboardActions = actions.Actions({
make.ConfirmAction('Delete', { make.ConfirmAction('Delete', {
callback: function(){ dialog.close() }, callback: function(){ dialog.close() },
timeout: that.config['confirm-delete-timeout'] || 2000, timeout: that.config['confirm-delete-timeout'] || 2000,
buttons: [
['Cancel', function(){
abort = true
make.dialog.close()
}],
],
}) })
}, },
{ {
@ -1158,6 +1165,10 @@ var KeyboardActions = actions.Actions({
// XXX at this point this does not account for changes // XXX at this point this does not account for changes
// in mode or code... // in mode or code...
.on('close', function(){ .on('close', function(){
if(abort){
return
}
// remove keys... // remove keys...
orig_keys orig_keys
.filter(function(k){ return keys.indexOf(k) < 0 }) .filter(function(k){ return keys.indexOf(k) < 0 })
@ -1180,6 +1191,7 @@ var KeyboardActions = actions.Actions({
editKeyboardMode: ['- Interface/Mode...', editKeyboardMode: ['- Interface/Mode...',
widgets.makeUIDialog(function(mode){ widgets.makeUIDialog(function(mode){
var that = this var that = this
var abort = false
var dialog = browse.makeLister(null, var dialog = browse.makeLister(null,
function(path, make){ function(path, make){
@ -1198,6 +1210,12 @@ var KeyboardActions = actions.Actions({
dialog.close() dialog.close()
}, },
timeout: that.config['confirm-delete-timeout'] || 2000, timeout: that.config['confirm-delete-timeout'] || 2000,
buttons: [
['Cancel', function(){
abort = true
make.dialog.close()
}],
],
}) })
}, },
{ {
@ -1206,33 +1224,20 @@ var KeyboardActions = actions.Actions({
return dialog return dialog
})], })],
// XXX BUG: for some reason we are adding one key at a time only...
// XXX revise: // XXX revise:
// - '*' toggle // - '*' toggle
// - done/cancel // - done/cancel
editKeyboardModeDroppedKeys: ['- Interface/Dropped keys...', editKeyboardModeDroppedKeys: ['- Interface/Dropped keys...',
widgets.makeUIDialog(function(mode){ widgets.makeUIDialog(function(mode){
var that = this var that = this
//var abort = false var abort = false
var abort = true var drop = (that.keybindings[mode].drop || []).slice()
var drop = that.keybindings[mode].drop || []
return browse.makeLister(null, return browse.makeLister(null,
function(path, make){ function(path, make){
var drop_all var drop_all
// '*' toggler...
// XXX should this close the dialog???
make.ConfirmAction('Drop all keys', {
callback: function(){
drop_all = '*'
make.dialog.close()
},
timeout: that.config['confirm-delete-timeout'] || 2000,
})
make('---')
// the list editor... // the list editor...
make.EditableList(function(keys){ make.EditableList(function(keys){
// get... // get...
@ -1248,24 +1253,24 @@ var KeyboardActions = actions.Actions({
unique: true unique: true
}) })
make('---') make.Separator()
//make.Action('Cancel') // '*' toggler...
// .on('open', function(){ // XXX should this close the dialog???
// abort = true make.ConfirmAction('Drop all keys', {
// make.dialog.close() callback: function(){
// }) drop_all = '*'
make.Action('Done', {
make.dialog.close()
},
timeout: that.config['confirm-delete-timeout'] || 2000,
buttons: [ buttons: [
['Cancel', function(){ ['Cancel', function(){
abort = true
make.dialog.close() make.dialog.close()
}], }],
]}) ],
.on('open', function(){ })
abort = false
make.dialog.close()
})
}) })
.on('close', function(){ .on('close', function(){
if(!abort){ if(!abort){

View File

@ -274,7 +274,7 @@ function(list, options){
: list : list
var editable = lst instanceof Array var editable = lst instanceof Array
// view objects... // view objects...
lst = !editable ? Object.keys(lst) : lst.slice() lst = !editable ? Object.keys(lst) : lst
// add the 'x' button if not disabled... // add the 'x' button if not disabled...
var buttons = options.buttons = (options.buttons || []).slice() var buttons = options.buttons = (options.buttons || []).slice()
@ -339,7 +339,7 @@ function(list, options){
: undefined) : undefined)
} }
write(list, lst) lst = write(list, lst)
// update list and select new value... // update list and select new value...
dialog.update() dialog.update()