From 3833545c5540586c39a552ae7a6a884c3a35cc70 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 29 Jan 2017 07:32:07 +0300 Subject: [PATCH] bugfix... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/keyboard.js | 6 ++++-- ui (gen4)/lib/widget/browse.js | 30 +++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ui (gen4)/features/keyboard.js b/ui (gen4)/features/keyboard.js index f19c1c8c..0adf1942 100755 --- a/ui (gen4)/features/keyboard.js +++ b/ui (gen4)/features/keyboard.js @@ -821,6 +821,7 @@ module.Keyboard = core.ImageGridFeatures.Feature({ //--------------------------------------------------------------------- +// XXX make these usable for any keyboard handler, not just the builtin... var KeyboardUIActions = actions.Actions({ config: { // NOTE: this is defined in ui-dialogs feature... @@ -828,6 +829,7 @@ var KeyboardUIActions = actions.Actions({ }, // XXX sub-group by path (???) + // XXX make this usable for other other handlers... browseKeyboardBindings: ['Help/Keyboard bindings...', core.doc`Keyboard bindings viewer... @@ -917,7 +919,7 @@ var KeyboardUIActions = actions.Actions({ var dialog = browse.makeLister(null, function(path, make){ var keys = kb.keys('*') - var keybindings = that.keybindings + var keybindings = kb.keyboard Object.keys(keybindings) .forEach(function(mode){ @@ -1227,7 +1229,7 @@ var KeyboardUIActions = actions.Actions({ dialog.newKey = function(){ that.editKeyBinding(this.select('!').attr('mode') - || Object.keys(that.keybindings)[0]) } + || Object.keys(kb.keyboard)[0]) } dialog.newMode = function(){ that.editKeyboardMode() } diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index ba1ba204..8671ad1a 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -1167,7 +1167,7 @@ var BrowserPrototype = { holdSize: 20, }, - // XXX TEST: this should prevent event propagation... + // XXX need a way to access buttons... // XXX should we have things like ctrl- for fast selection // in filter mode??? keybindings: { @@ -1561,9 +1561,8 @@ var BrowserPrototype = { // // item format: // - str - item text - // NOTE: if text is '---' then a - // separator item is created, it is - // not selectable (default:
). + // NOTE: see: .options.elementShorthand + // for shorthands for common elements // // - [str/func, ... ] - item elements // Each of the elements is individually @@ -1582,6 +1581,16 @@ var BrowserPrototype = { // Both traversable and disabled are optional and can take bool // values. // + // If item matches .options.itemShortcutMarker (default: /\$(\w)/) + // then the char after the '$' will be used as a keyboard shortcut + // for this item the char wrapped in a span (class: .keyboard-shortcut), + // and the marker (in this case '$') will be cleaned out. + // Also see: item.options.shortcut_key below. + // + // NOTE: only the first occurrence of key will get registered... + // NOTE: shortcuts can't override Browse shortcuts... + // + // // options format: // { // // If true make the element traversable... @@ -1942,10 +1951,13 @@ var BrowserPrototype = { // text marker... if(item_shortcut_marker){ + var did_register = false var _replace = function(){ // get the last group... var key = [].slice.call(arguments).slice(-3)[0] !item_shortcuts[key] + // NOTE: this is a side-effect... + && (did_register = true) && that.keyboard.handler( 'ItemShortcuts', key, @@ -1960,9 +1972,13 @@ var BrowserPrototype = { e = $(e) e.html(e.html().replace(item_shortcut_marker, function(){ - return '' - +_replace.apply(this, arguments) - +'' })) }) + did_register = false + var k = _replace.apply(this, arguments) + return !did_register ? + `${k}` + : k + })) + }) } } //---------------------------------------------------------