mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
added key repeat limiting + minor doc tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
79cb149a4b
commit
9489f9023e
@ -180,6 +180,50 @@ function normalizeModifiers(c, m, a, s){
|
||||
}
|
||||
|
||||
|
||||
// Event handler wrapper that will drop identical keys repeating at rate
|
||||
// greater than max_rate
|
||||
//
|
||||
// NOTE: this will only limit repeating key combinations thus no lag is
|
||||
// introduced...
|
||||
var dropRepeatingkeys =
|
||||
module.dropRepeatingkeys =
|
||||
function dropRepeatingkeys(handler, max_rate){
|
||||
var _timeout = null
|
||||
|
||||
var key = null
|
||||
|
||||
var ctrl = null
|
||||
var meta = null
|
||||
var alt = null
|
||||
var shift = null
|
||||
|
||||
return function(evt){
|
||||
if(_timeout != null
|
||||
&& key == evt.keyCode
|
||||
&& ctrl == evt.ctrlKey
|
||||
&& meta == evt.metaKey
|
||||
&& alt == evt.altKey
|
||||
&& shift == evt.shiftKey){
|
||||
return
|
||||
}
|
||||
|
||||
key = evt.keyCode
|
||||
ctrl = evt.ctrlKey
|
||||
meta = evt.metaKey
|
||||
alt = evt.altKey
|
||||
shift = evt.shiftKey
|
||||
|
||||
_timeout = setTimeout(function(){
|
||||
_timeout = null
|
||||
},
|
||||
// XXX is this the right way to go???
|
||||
typeof(max_rate) == typeof(123) ? max_rate : max_rate())
|
||||
|
||||
return handler(evt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Key handler getter
|
||||
*
|
||||
* For doc on format see makeKeyboardHandler(...)
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "ImageGrid.Viewer",
|
||||
"name": "ImageGrid.Viewer (gen4)",
|
||||
"main": "index.html",
|
||||
"version": "0.0.1",
|
||||
"window": {
|
||||
"title": "ImageGrid.Viewer",
|
||||
"title": "ImageGrid.Viewer (gen4)",
|
||||
"position": "center",
|
||||
"width": 900,
|
||||
"height": 700,
|
||||
|
||||
@ -61,6 +61,9 @@ var overlay = require('lib/widget/overlay')
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
// XXX move this to config...
|
||||
module.MAX_KEY_REPEAT_RATE = 100
|
||||
|
||||
// XXX add this to the global doc...
|
||||
module.GLOBAL_KEYBOARD = {
|
||||
'Global bindings': {
|
||||
@ -229,7 +232,6 @@ module.GLOBAL_KEYBOARD = {
|
||||
|
||||
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
$(function(){
|
||||
@ -278,12 +280,17 @@ $(function(){
|
||||
// setup base keyboard for devel, in case something breaks...
|
||||
$(document)
|
||||
.keydown(
|
||||
keyboard.makeKeyboardHandler(
|
||||
module.GLOBAL_KEYBOARD,
|
||||
function(k){
|
||||
window.DEBUG && console.log(k)
|
||||
},
|
||||
a))
|
||||
keyboard.dropRepeatingkeys(
|
||||
keyboard.makeKeyboardHandler(
|
||||
module.GLOBAL_KEYBOARD,
|
||||
function(k){
|
||||
window.DEBUG && console.log(k)
|
||||
},
|
||||
a),
|
||||
function(){
|
||||
// XXX get this from config...
|
||||
return module.MAX_KEY_REPEAT_RATE
|
||||
}))
|
||||
})
|
||||
|
||||
|
||||
|
||||
@ -2547,17 +2547,17 @@ module.ImageBookmarks = features.Feature(ImageGridFeatures, {
|
||||
|
||||
var AppControlActions = actions.Actions({
|
||||
// XXX revise these...
|
||||
close: ['Cloase viewer',
|
||||
close: ['File|Interface/Cloase viewer',
|
||||
function(){
|
||||
// XXX should we do anything else here like auto-save???
|
||||
window.close()
|
||||
}],
|
||||
toggleFullScreen: ['',
|
||||
toggleFullScreen: ['Interface/Toggle full screen mode',
|
||||
function(){
|
||||
// XXX where should toggleFullscreenMode(..) be defined...
|
||||
toggleFullscreenMode()
|
||||
}],
|
||||
showDevTools: ['',
|
||||
showDevTools: ['Interface|Development/Show Dev Tools',
|
||||
function(){
|
||||
if(window.showDevTools != null){
|
||||
showDevTools()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user