added list of ignored keys to cursor autohiding...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-01-11 21:08:29 +03:00
parent b4d7ee058b
commit 54ffa699e1
3 changed files with 27 additions and 10 deletions

View File

@ -391,7 +391,7 @@ module.GLOBAL_KEYBOARD2 = {
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// XXX DEBUG: remove when done... /*/ XXX DEBUG: remove when done...
window.kb = keyboard.Keyboard( window.kb = keyboard.Keyboard(
GLOBAL_KEYBOARD, GLOBAL_KEYBOARD,
function checkGlobalMode(mode, keyboard, context){ function checkGlobalMode(mode, keyboard, context){
@ -399,6 +399,7 @@ window.kb = keyboard.Keyboard(
return !pattern return !pattern
|| pattern == '*' || pattern == '*'
|| $(keyboard[mode].pattern).length > 0 }) || $(keyboard[mode].pattern).length > 0 })
//*/
@ -574,9 +575,10 @@ var KeyboardActions = actions.Actions({
// NOTE: the target element must be focusable... // NOTE: the target element must be focusable...
var target = var target =
this.__keyboard_event_source = 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'] == 'viewer' ? this.ribbons.viewer
: this.config['keyboard-event-source'] == 'window' ? $(window)
: this.config['keyboard-event-source'] == 'document' ? $(document) : this.config['keyboard-event-source'] == 'document' ? $(document)
: $(this.config['keyboard-event-source']) : $(this.config['keyboard-event-source'])

View File

@ -40,6 +40,7 @@
var toggler = require('lib/toggler') var toggler = require('lib/toggler')
var actions = require('lib/actions') var actions = require('lib/actions')
var features = require('lib/features') var features = require('lib/features')
var keyboard = require('lib/keyboard2')
var data = require('imagegrid/data') var data = require('imagegrid/data')
var images = require('imagegrid/images') var images = require('imagegrid/images')
@ -1603,6 +1604,10 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
], ],
config: { config: {
'cursor-autohide-ignore-keys': [
'shift', 'ctrl', 'alt', 'meta',
],
'cursor-autohide': 'on', 'cursor-autohide': 'on',
'cursor-autohide-on-timeout': 'off', 'cursor-autohide-on-timeout': 'off',
'cursor-autohide-on-keyboard': 'on', 'cursor-autohide-on-keyboard': 'on',
@ -1675,7 +1680,6 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
// setup... // setup...
if(state == 'on'){ if(state == 'on'){
var x, y
var timer var timer
var timeout = var timeout =
that.toggleAutoHideCursorTimeout('?') == 'on' ? that.toggleAutoHideCursorTimeout('?') == 'on' ?
@ -1716,16 +1720,24 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
var key_handler var key_handler
= this.__cursor_autohide_key_handler = this.__cursor_autohide_key_handler
= (this.__cursor_autohide_key_handler = (this.__cursor_autohide_key_handler
|| function(){ || function(evt){
var viewer = that.ribbons.viewer var viewer = that.ribbons.viewer
// get key...
var key = keyboard.normalizeKey(
keyboard.event2key(evt))
.join('+')
// auto-hide is off -- restore... // auto-hide is off -- restore...
if(!viewer.hasClass('cursor-autohide')){ if(!viewer.hasClass('cursor-autohide')){
that.toggleHiddenCursor('off') that.toggleHiddenCursor('off')
return 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') && that.toggleHiddenCursor('on')
return true return true

View File

@ -260,16 +260,19 @@ function normalizeKey(key){
key = splitKey(key) key = splitKey(key)
.slice() .slice()
.sort(function(a, b){ .sort(function(a, b){
a = modifiers.indexOf(a) a = modifiers.indexOf(a.toLowerCase())
b = modifiers.indexOf(b) b = modifiers.indexOf(b.toLowerCase())
return a >= 0 && b >= 0 ? a - b return a >= 0 && b >= 0 ? a - b
: a < 0 ? 1 : a < 0 ? 1
: -1 }) : -1 })
var k = key.pop() var k = key.pop()
k = parseInt(k) ? code2key(parseInt(k)) : k.capitalize() k = parseInt(k) ? code2key(parseInt(k)) : k
key = key.unique() k = modifiers.indexOf(k.toLowerCase()) >= 0 ?
k.toLowerCase()
: k.capitalize()
key.push(k) key.push(k)
key = key.unique()
return output == 'array' ? return output == 'array' ?
key key