KeyShortcutHandler allow force register item
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
(when xKey
|
||||
(when (= keyHandler.cancelKey xKey)
|
||||
(set keyHandler.cancelKey null))
|
||||
(xHandler.registerItem "{${xKey}}" closeAction))))
|
||||
(xHandler.registerItem "{${xKey}}" closeAction true))))
|
||||
|
||||
// TODO show which shortcuts' prefixes are partially highlighted?
|
||||
)
|
||||
@@ -148,7 +148,7 @@
|
||||
(dictSet _actions ftext ->:Void _ (scrollLeft))
|
||||
(set leftText ftext))
|
||||
(when leftKey
|
||||
(xHandler.registerItem "{${leftKey}}" scrollLeft))
|
||||
(xHandler.registerItem "{${leftKey}}" scrollLeft true))
|
||||
(let [ftext (new FlxText width height 0 "->" textSize)]
|
||||
(set ftext.cameras [controlCamera])
|
||||
(-= ftext.x ftext.width)
|
||||
@@ -159,7 +159,7 @@
|
||||
(dictSet _actions ftext ->:Void _ (scrollRight))
|
||||
(set rightText ftext))
|
||||
(when rightKey
|
||||
(xHandler.registerItem "{${rightKey}}" scrollRight))
|
||||
(xHandler.registerItem "{${rightKey}}" scrollRight true))
|
||||
(refreshColumnTexts)
|
||||
|
||||
(set hasScrollArrows true))
|
||||
|
@@ -71,11 +71,11 @@
|
||||
(otherwise
|
||||
shortcuts)))
|
||||
|
||||
(method :Void registerShortcut [keys description item &opt :PrefixMap<T> prefixMap]
|
||||
(method :Void registerShortcut [keys description item &opt :Bool force :PrefixMap<T> prefixMap]
|
||||
(unless prefixMap (set prefixMap rootMap))
|
||||
(let [firstKey (keys.shift)]
|
||||
(cond
|
||||
((or (prefixMap.exists firstKey) (= firstKey cancelKey))
|
||||
((and !force (or (prefixMap.exists firstKey) (= firstKey cancelKey)))
|
||||
(let [existingKey (if (= firstKey cancelKey) (Cancel cancelKey) (dictGet prefixMap firstKey))
|
||||
conflictMessage "Keyboard shortcut for $description conflicts with $existingKey"]
|
||||
(if keys
|
||||
@@ -94,12 +94,12 @@
|
||||
(if keys
|
||||
(let [innerPrefixMap (new Map)]
|
||||
(dictSet prefixMap firstKey (Prefix innerPrefixMap))
|
||||
(registerShortcut keys description item innerPrefixMap))
|
||||
(registerShortcut keys description item force innerPrefixMap))
|
||||
(dictSet prefixMap firstKey (Final item)))))))
|
||||
|
||||
(method :Void registerItem [description :T item]
|
||||
(method :Void registerItem [description :T item &opt :Bool force]
|
||||
(whenLet [keyboardShortcut (extractKeyboardShortcuts description)]
|
||||
(registerShortcut keyboardShortcut description item)))
|
||||
(registerShortcut keyboardShortcut description item force)))
|
||||
|
||||
(method :Map<String,String> prefixMapToStrings [:PrefixMap<T> map]
|
||||
(for =>key mapping map
|
||||
|
Reference in New Issue
Block a user