Forum at OOoForum.orgThe Forum
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to include backspace in "textcursor.setstring"

Post new topic   Reply to topic Forum Index -> Macros and API
View previous topic :: View next topic  
Author Message
General User
General User

Joined: 30 Jan 2009
Posts: 8

PostPosted: Fri Jan 30, 2009 4:31 am    Post subject: How to include backspace in "textcursor.setstring" Reply with quote


I have a key handler in a macro which contextually determines the text from the key pressed. ( I am actually writing a macro to type Sanskrit in OO phonetically, slightly different in behavior from the keyboard layouts already available.) This sometimes requires that i backspace an already displayed character. Including ASCII code for backspace in the string argument to setstring literally outputs a code on to the document. (However I can achieve the desired result by searching for backspace in the string and moving the cursor back). This seems a little unintuitive to me. This does not seem to be the behaviour on microsoft office word. Is there an easy way around this ?

I have provided the working code below.

Function KeyHandler_keyPressed(oKeyEvent as new As Boolean

Dim myDoc as Object
Dim controller as Object
Dim viewCursor as Object
Dim myText as Object
Dim textCursor as Object
Dim aString as String
Dim rString as string
dim ctxtChr
dim i, j
dim c
dim texta, tmp

myDoc = ThisComponent
controller = myDoc.getCurrentController()
viewCursor = controller.getViewCursor()
myText = viewCursor.getText()
textCursor = myText.createTextCursorByRange(viewCursor)

textCursor.goLeft(1, true)
aString = textCursor.getString()
if (aString = "") then
ctxtChr = uc_Ig
ctxtChr = asc(aString)
end if
KeyHandler_keyPressed = processKey(oKeyEvent.keyChar, ctxtChr, rString)
if not (rString = "") then
for i = 1 to len(rString)
j = mid(rString,i,1)
if (asc(j) = Cool then
textCursor.goLeft(1, true)
end if

etc etc

Thanks and Regards
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Forum Index -> Macros and API All times are GMT - 8 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group