mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00: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 | /* Key handler getter | ||||||
|  * |  * | ||||||
|  * For doc on format see makeKeyboardHandler(...) |  * For doc on format see makeKeyboardHandler(...) | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| { | { | ||||||
|   "name": "ImageGrid.Viewer", |   "name": "ImageGrid.Viewer (gen4)", | ||||||
|   "main": "index.html", |   "main": "index.html", | ||||||
|   "version": "0.0.1", |   "version": "0.0.1", | ||||||
|   "window": { |   "window": { | ||||||
|     "title": "ImageGrid.Viewer", |     "title": "ImageGrid.Viewer (gen4)", | ||||||
|     "position": "center", |     "position": "center", | ||||||
|     "width": 900, |     "width": 900, | ||||||
|     "height": 700, |     "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...
 | // XXX add this to the global doc...
 | ||||||
| module.GLOBAL_KEYBOARD = { | module.GLOBAL_KEYBOARD = { | ||||||
| 	'Global bindings': { | 	'Global bindings': { | ||||||
| @ -229,7 +232,6 @@ module.GLOBAL_KEYBOARD = { | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /*********************************************************************/ | /*********************************************************************/ | ||||||
| 
 | 
 | ||||||
| $(function(){ | $(function(){ | ||||||
| @ -278,12 +280,17 @@ $(function(){ | |||||||
| 	// setup base keyboard for devel, in case something breaks...
 | 	// setup base keyboard for devel, in case something breaks...
 | ||||||
| 	$(document) | 	$(document) | ||||||
| 		.keydown( | 		.keydown( | ||||||
| 			keyboard.makeKeyboardHandler( | 			keyboard.dropRepeatingkeys( | ||||||
| 				module.GLOBAL_KEYBOARD, | 				keyboard.makeKeyboardHandler( | ||||||
| 				function(k){ | 					module.GLOBAL_KEYBOARD, | ||||||
| 					window.DEBUG && console.log(k) | 					function(k){ | ||||||
| 				},  | 						window.DEBUG && console.log(k) | ||||||
| 				a)) | 					},  | ||||||
|  | 					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({ | var AppControlActions = actions.Actions({ | ||||||
| 	// XXX revise these...
 | 	// XXX revise these...
 | ||||||
| 	close: ['Cloase viewer', | 	close: ['File|Interface/Cloase viewer', | ||||||
| 		function(){ | 		function(){ | ||||||
| 			// XXX should we do anything else here like auto-save???
 | 			// XXX should we do anything else here like auto-save???
 | ||||||
| 			window.close()  | 			window.close()  | ||||||
| 		}], | 		}], | ||||||
| 	toggleFullScreen: ['', | 	toggleFullScreen: ['Interface/Toggle full screen mode', | ||||||
| 		function(){ | 		function(){ | ||||||
| 			// XXX where should toggleFullscreenMode(..) be defined...
 | 			// XXX where should toggleFullscreenMode(..) be defined...
 | ||||||
| 			toggleFullscreenMode()  | 			toggleFullscreenMode()  | ||||||
| 		}], | 		}], | ||||||
| 	showDevTools: ['', | 	showDevTools: ['Interface|Development/Show Dev Tools', | ||||||
| 		function(){ | 		function(){ | ||||||
| 			if(window.showDevTools != null){ | 			if(window.showDevTools != null){ | ||||||
| 				showDevTools()  | 				showDevTools()  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user