diff --git a/ui (gen4)/features/keyboard.js b/ui (gen4)/features/keyboard.js index 863ac0ea..8f11309b 100755 --- a/ui (gen4)/features/keyboard.js +++ b/ui (gen4)/features/keyboard.js @@ -391,7 +391,7 @@ module.GLOBAL_KEYBOARD2 = { //--------------------------------------------------------------------- -// XXX DEBUG: remove when done... +/*/ XXX DEBUG: remove when done... window.kb = keyboard.Keyboard( GLOBAL_KEYBOARD, function checkGlobalMode(mode, keyboard, context){ @@ -399,6 +399,7 @@ window.kb = keyboard.Keyboard( return !pattern || pattern == '*' || $(keyboard[mode].pattern).length > 0 }) +//*/ @@ -574,9 +575,10 @@ var KeyboardActions = actions.Actions({ // NOTE: the target element must be focusable... var target = this.__keyboard_event_source = - this.config['keyboard-event-source'] ? $(window) + (this.config['keyboard-event-source'] + || this.config['keyboard-event-source'] == 'window') ? + $(window) : this.config['keyboard-event-source'] == 'viewer' ? this.ribbons.viewer - : this.config['keyboard-event-source'] == 'window' ? $(window) : this.config['keyboard-event-source'] == 'document' ? $(document) : $(this.config['keyboard-event-source']) diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js index b8316d8f..d58f2a30 100755 --- a/ui (gen4)/features/ui.js +++ b/ui (gen4)/features/ui.js @@ -40,6 +40,7 @@ var toggler = require('lib/toggler') var actions = require('lib/actions') var features = require('lib/features') +var keyboard = require('lib/keyboard2') var data = require('imagegrid/data') var images = require('imagegrid/images') @@ -1603,6 +1604,10 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({ ], config: { + 'cursor-autohide-ignore-keys': [ + 'shift', 'ctrl', 'alt', 'meta', + ], + 'cursor-autohide': 'on', 'cursor-autohide-on-timeout': 'off', 'cursor-autohide-on-keyboard': 'on', @@ -1675,7 +1680,6 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({ // setup... if(state == 'on'){ - var x, y var timer var timeout = that.toggleAutoHideCursorTimeout('?') == 'on' ? @@ -1716,16 +1720,24 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({ var key_handler = this.__cursor_autohide_key_handler = (this.__cursor_autohide_key_handler - || function(){ + || function(evt){ var viewer = that.ribbons.viewer + // get key... + var key = keyboard.normalizeKey( + keyboard.event2key(evt)) + .join('+') + // auto-hide is off -- restore... if(!viewer.hasClass('cursor-autohide')){ that.toggleHiddenCursor('off') return } - that.toggleAutoHideCursorKeyboard('?') == 'on' + // hide if mode is on and non-ignored key... + (that.config['cursor-autohide-ignore-keys'] + || []).indexOf(key) < 0 + && that.toggleAutoHideCursorKeyboard('?') == 'on' && that.toggleHiddenCursor('on') return true diff --git a/ui (gen4)/lib/keyboard2.js b/ui (gen4)/lib/keyboard2.js index cd05ebd2..59cbe723 100755 --- a/ui (gen4)/lib/keyboard2.js +++ b/ui (gen4)/lib/keyboard2.js @@ -260,16 +260,19 @@ function normalizeKey(key){ key = splitKey(key) .slice() .sort(function(a, b){ - a = modifiers.indexOf(a) - b = modifiers.indexOf(b) + a = modifiers.indexOf(a.toLowerCase()) + b = modifiers.indexOf(b.toLowerCase()) return a >= 0 && b >= 0 ? a - b : a < 0 ? 1 : -1 }) var k = key.pop() - k = parseInt(k) ? code2key(parseInt(k)) : k.capitalize() - key = key.unique() + k = parseInt(k) ? code2key(parseInt(k)) : k + k = modifiers.indexOf(k.toLowerCase()) >= 0 ? + k.toLowerCase() + : k.capitalize() key.push(k) + key = key.unique() return output == 'array' ? key