#TUNING by sr
cache unusedShortCuts to get rid of the input delay from nested menu panels ans sub views
class: KeyboardProcessor
class definition
changed: #processEvent:forModalView:
--- a/KeyboardProcessor.st Fri Jun 29 17:59:59 2018 +0200
+++ b/KeyboardProcessor.st Tue Jul 03 16:17:48 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1997 by eXept Software AG
All Rights Reserved
@@ -16,7 +18,8 @@
Object subclass:#KeyboardProcessor
instanceVariableNames:'returnIsOKInDialog escapeIsCancelInDialog menuBar
autoAcceptListeners globalAccelerators componentWithInitialFocus
- altFunctionWasExecuted eventFilter returnAction cancelAction'
+ altFunctionWasExecuted eventFilter returnAction cancelAction
+ unusedShortCutsCache'
classVariableNames:''
poolDictionaries:''
category:'Interface-Framework'
@@ -234,7 +237,7 @@
<resource: #keyboard (#Return #Escape #CloseWindowRequest)>
- |key rawKey topView wg app view action explicitFocusView focusView|
+ |key rawKey topView wg app view action explicitFocusView focusView isUnusedShortCut|
event isKeyEvent ifFalse:[ ^ false ].
@@ -364,9 +367,33 @@
(self class isKeyEventIgnoredAsShortcut:event) ifFalse:[
"/Transcript showCR:event rawKey.
"/Transcript showCR:event key.
- (wg processShortcut:event) ifTrue:[
- ^ true
- ].
+
+ "sr: after discussion with cg,
+ we decided to cache shortcuts with no actions.
+ we also know about the fact that this will ignore short cuts
+ from dynamic menus/views (but we decided to dont care)"
+ isUnusedShortCut := false.
+
+ (rawKey notNil
+ and:[unusedShortCutsCache notNil]) ifTrue:[
+ (unusedShortCutsCache includesIdentical:rawKey asSymbol) ifTrue:[
+ isUnusedShortCut := true.
+ ].
+ ].
+
+ isUnusedShortCut ifFalse:[
+ (wg processShortcut:event) ifTrue:[
+ ^ true
+ ] ifFalse:[
+ unusedShortCutsCache isNil ifTrue:[
+ "sr: I dont care about sync here,
+ because in worst case some shortcuts are calculated (to be unused) twice"
+ unusedShortCutsCache := IdentitySet new.
+ ].
+
+ unusedShortCutsCache add:rawKey asSymbol
+ ].
+ ].
].
].
"/ support ALT-F4 (close window)
@@ -384,6 +411,7 @@
"Modified: / 18-07-2011 / 09:47:57 / cg"
"Modified (comment): / 13-02-2017 / 20:26:23 / cg"
+ "Modified: / 03-07-2018 / 16:14:09 / sr"
!
requestForWindowClose