Allow arrow keys in Normal mode and move some code to KeyReleased

This commit is contained in:
Sean Yeh 2014-12-22 17:36:54 -06:00
parent c95177247a
commit 65780b1896
1 changed files with 12 additions and 6 deletions

View File

@ -229,12 +229,13 @@ function KeyHandler_KeyPressed(oEvent) as boolean
Exit Function Exit Function
End If End If
dim bConsumeInput, bIsMultiplier, bIsModified, bIsSpecial, oTextCursor dim bConsumeInput, bIsMultiplier, bIsModified, bIsSpecial
bConsumeInput = True ' Block all inputs by default bConsumeInput = True ' Block all inputs by default
bIsMultiplier = False ' reset multiplier by default bIsMultiplier = False ' reset multiplier by default
bIsModified = oEvent.Modifiers > 1 ' If Ctrl or Alt is held down. (Shift=1) bIsModified = oEvent.Modifiers > 1 ' If Ctrl or Alt is held down. (Shift=1)
bIsSpecial = getSpecial() <> "" bIsSpecial = getSpecial() <> ""
' -------------------------- ' --------------------------
' Process global shortcuts, exit if matched (like ESC) ' Process global shortcuts, exit if matched (like ESC)
If ProcessGlobalKey(oEvent) Then If ProcessGlobalKey(oEvent) Then
@ -273,10 +274,13 @@ function KeyHandler_KeyPressed(oEvent) as boolean
ElseIf ProcessMovementModifierKey(oEvent.KeyChar) Then ElseIf ProcessMovementModifierKey(oEvent.KeyChar) Then
delaySpecialReset() delaySpecialReset()
' If bIsSpecial but nothing matched, return to normal mode ' If bIsSpecial but nothing matched, return to normal mode
ElseIf bIsSpecial Then ElseIf bIsSpecial Then
gotoMode("NORMAL") gotoMode("NORMAL")
' Allow non-letter keys if unmatched
ElseIf asc(oEvent.KeyChar) = 0 Then
bConsumeInput = False
End If End If
' -------------------------- ' --------------------------
@ -289,6 +293,12 @@ function KeyHandler_KeyPressed(oEvent) as boolean
End If End If
setStatus(getMultiplier()) setStatus(getMultiplier())
KeyHandler_KeyPressed = bConsumeInput
End Function
Function KeyHandler_KeyReleased(oEvent) As boolean
dim oTextCursor
' Show terminal-like cursor ' Show terminal-like cursor
oTextCursor = getTextCursor() oTextCursor = getTextCursor()
If oEvent.Modifiers = 2 Or oEvent.Modifiers = 8 And oEvent.KeyChar = "c" Then If oEvent.Modifiers = 2 Or oEvent.Modifiers = 8 And oEvent.KeyChar = "c" Then
@ -301,10 +311,6 @@ function KeyHandler_KeyPressed(oEvent) as boolean
thisComponent.getCurrentController.Select(oTextCursor) thisComponent.getCurrentController.Select(oTextCursor)
End If End If
KeyHandler_KeyPressed = bConsumeInput
End Function
Function KeyHandler_KeyReleased(oEvent) As boolean
KeyHandler_KeyReleased = (MODE = "NORMAL") 'cancel KeyReleased KeyHandler_KeyReleased = (MODE = "NORMAL") 'cancel KeyReleased
End Function End Function