#21: Fix annotation insertion error

This commit is contained in:
Sean Yeh 2015-07-24 08:37:44 -05:00
parent a56f772962
commit f25a3bfff4
1 changed files with 24 additions and 3 deletions

View File

@ -46,10 +46,15 @@ End Function
Function getTextCursor Function getTextCursor
dim oTextCursor dim oTextCursor
On Error Goto ErrorHandler
oTextCursor = getCursor().getText.createTextCursorByRange(getCursor()) oTextCursor = getCursor().getText.createTextCursorByRange(getCursor())
' oTextCursor.gotoRange(oTextCursor.getStart(), False)
getTextCursor = oTextCursor getTextCursor = oTextCursor
Exit Function
ErrorHandler:
' Text Cursor does not work in some instances, such as in Annotations
getTextCursor = Nothing
End Function End Function
' ----------------- ' -----------------
@ -251,12 +256,21 @@ End Sub
' Main Key Processing ' Main Key Processing
' -------------------- ' --------------------
function KeyHandler_KeyPressed(oEvent) as boolean function KeyHandler_KeyPressed(oEvent) as boolean
dim oTextCursor
' Exit if plugin is not enabled ' Exit if plugin is not enabled
If IsMissing(VIBREOFFICE_ENABLED) Or Not VIBREOFFICE_ENABLED Then If IsMissing(VIBREOFFICE_ENABLED) Or Not VIBREOFFICE_ENABLED Then
KeyHandler_KeyPressed = False KeyHandler_KeyPressed = False
Exit Function Exit Function
End If End If
' Exit if TextCursor does not work (as in Annotations)
oTextCursor = getTextCursor()
If oTextCursor Is Nothing Then
KeyHandler_KeyPressed = False
Exit Function
End If
dim bConsumeInput, bIsMultiplier, bIsModified, bIsSpecial 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
@ -333,7 +347,9 @@ Function KeyHandler_KeyReleased(oEvent) As boolean
' 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 oTextCursor Is Nothing Then
' Do nothing
ElseIf oEvent.Modifiers = 2 Or oEvent.Modifiers = 8 And oEvent.KeyChar = "c" Then
' Allow Ctrl+c for Copy, so don't change cursor ' Allow Ctrl+c for Copy, so don't change cursor
' Pass ' Pass
ElseIf MODE = "NORMAL" Then ElseIf MODE = "NORMAL" Then
@ -976,7 +992,12 @@ Sub initVibreoffice
' Show terminal cursor ' Show terminal cursor
oTextCursor = getTextCursor() oTextCursor = getTextCursor()
cursorReset(oTextCursor)
If oTextCursor Is Nothing Then
' Do nothing
Else
cursorReset(oTextCursor)
End If
sStartXKeyHandler() sStartXKeyHandler()
End Sub End Sub