From 10d95266064323e2d578879b3726c1f22c22797b Mon Sep 17 00:00:00 2001 From: Kai Labusch Date: Fri, 13 Dec 2019 14:20:12 +0100 Subject: [PATCH] make table edit keys more robust against multiple activations by accident --- neath.js | 73 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/neath.js b/neath.js index a3eb254..aa1e292 100644 --- a/neath.js +++ b/neath.js @@ -444,32 +444,53 @@ function setupInterface(data, file, urls) { let row_listener = new window.keypress.Listener(row, listener_defaults); - row_listener.sequence_combo('0', - function() { - - data.data[row.data('tableInfo').nRow]['No.'] = 0; - - row.children('.editable').first().html('0'); - - notifyChange(); - }); - - row_listener.sequence_combo('s t', function() { - tableEditAction(row.data('tableInfo').nRow, 'sentence'); - }); - - row_listener.sequence_combo('s p', function() { - tableEditAction(row.data('tableInfo').nRow, 'split'); - }); - - row_listener.sequence_combo('m e', function() { - tableEditAction(row.data('tableInfo').nRow, 'merge'); - }); - - row_listener.sequence_combo('d l', function() { - tableEditAction(row.data('tableInfo').nRow, 'delete'); - }); - + row_listener.register_many( + [ + { + keys: 's t', + on_keydown: + function() { + tableEditAction(row.data('tableInfo').nRow, 'sentence'); + }, + is_sequence: true, + is_solitary: true, + is_exclusive: true + }, + + { + keys: 's p', + on_keydown: + function() { + tableEditAction(row.data('tableInfo').nRow, 'split'); + }, + is_sequence: true, + is_solitary: true, + is_exclusive: true + }, + + { + keys: 'm e', + on_keydown: + function() { + tableEditAction(row.data('tableInfo').nRow, 'merge'); + }, + is_sequence: true, + is_solitary: true, + is_exclusive: true + }, + + { + keys: 'd l', + on_keydown: + function() { + tableEditAction(row.data('tableInfo').nRow, 'delete'); + }, + is_sequence: true, + is_solitary: true, + is_exclusive: true + } + ] + ); $.each(el, function(column, content) {