BASIC - Howto handle selected text in a textbox ?
BASIC - Howto handle selected text in a textbox ?
just that, how to handle the selected text into the textbox field. For example if we want to select the two first characters on the text.
thx in advance
thx in advance
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Re: BASIC - Howto handle selected text in a textbox ?
Hi,
as a beginning :
Apollo102
as a beginning :
Code: Select all
Sub TextBox()
Dim oDoc As Object
Dim oShapes As Object
Dim oShape As Object
Dim oTextBox As Object
Dim oTextCursor As Object
Dim s As Integer 'Shape-No
oDoc = ThisComponent
oShapes = oDoc.DrawPage
for s = 0 to oShapes.getCount() - 1
oShape = oShapes.getByIndex(s)
If (oShape.getShapeType() = "com.sun.star.drawing.TextShape") then
oTextBox = oShape
oTextCursor = oTextBox.Text.createTextCursor()
oTextCursor.gotoStart(false)
oTextCursor.goRight(2,true)
MsgBox oTextCursor.getString()
oTextCursor.setString("22")
' oTextBox.setString("Hi")
' MsgBox oTextBox.getString()
End if
Next s
End Sub
OpenOffice 4.2 MacOS
Re: BASIC - Howto handle selected text in a textbox ?
so isnt there the SelStart and SelLength procedures like in vb ?
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Re: BASIC - Howto handle selected text in a textbox ?
OpenOffice has its own method's and you can't just use function names from MS Office.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: BASIC - Howto handle selected text in a textbox ?
I don't know a way. You also could not go through the detour of a bookmark, because you can not paste it into a text shape.
OpenOffice 4.2 MacOS
Re: BASIC - Howto handle selected text in a textbox ?
Hello
I think this interface is the best to use.
http://www.openoffice.org/api/docs/comm ... onent.html
The reason it can be used for a single line and a multiline texstbox. The interface is part of the view of the control and not of the model.
Romke
I think this interface is the best to use.
http://www.openoffice.org/api/docs/comm ... onent.html
The reason it can be used for a single line and a multiline texstbox. The interface is part of the view of the control and not of the model.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: BASIC - Howto handle selected text in a textbox ?
yes, i want to use the text selection to handle a predictive text from a table. I did it with vb6 ages ago, but with specific functions for the text select...
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Re: BASIC - Howto handle selected text in a textbox ?
Do you have an example of this? I still do not understand how to achieve that.RPG wrote:Hello
I think this interface is the best to use.
http://www.openoffice.org/api/docs/comm ... onent.html
The reason it can be used for a single line and a multiline texstbox. The interface is part of the view of the control and not of the model.
Romke
Thank you
OpenOffice 4.2 MacOS
Re: BASIC - Howto handle selected text in a textbox ?
Hello
A textbox does have the property "hide selection". Maybe you have to test how to set it for you. Do test it after the macro is working when the focus is on the control.
A textbox does have the property "hide selection". Maybe you have to test how to set it for you. Do test it after the macro is working when the focus is on the control.
Code: Select all
sub selecttextincontrol(oEvent as object)
'I did use the event : Mouse out side
dim strucselection as new com.sun.star.awt.Selection
dim oTextControl
oTextControl=oEvent.source
'mri oTextControl
strucselection.min=1
strucselection.max=3
oTextControl.setSelection(strucselection)
exit sub
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: BASIC - Howto handle selected text in a textbox ?
I'm very sorry. But I still do not understand how it is applied to a textshape. I would be interested to see how that goes.
THX
THX
OpenOffice 4.2 MacOS
Re: BASIC - Howto handle selected text in a textbox ?
Hello
I understand this topic as: How do we select text in a text control in a data-form for a database form.
I have little knowledge of shapes but I have the idea they do not contain text. A textcontrol does have a a shape but this is most of the time not important for the programmer.
The topic starter works with database forms and controls in data-forms.
Romke
I understand this topic as: How do we select text in a text control in a data-form for a database form.
I have little knowledge of shapes but I have the idea they do not contain text. A textcontrol does have a a shape but this is most of the time not important for the programmer.
The topic starter works with database forms and controls in data-forms.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: BASIC - Howto handle selected text in a textbox ?
yes, this is what i need. Just to be able to select the number of characters that i want into a textbox field.
example, if the textbox contains 'Apache OpenOffice', i want to select just 'Apache'
example, if the textbox contains 'Apache OpenOffice', i want to select just 'Apache'
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Re: BASIC - Howto handle selected text in a textbox ?
"Text shape" may refer to something from the "Drawing" toolbar.
"Text box" may refer to something from Insert>Fields>Other... or a form control.
"Text box" may refer to something from Insert>Fields>Other... or a form control.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: BASIC - Howto handle selected text in a textbox ?
Sorry then I was wrong. I've always thought about a textshape in a DrawPage. A DrawPage which is included in a writer document. I misunderstood the topic.
OpenOffice 4.2 MacOS
Re: BASIC - Howto handle selected text in a textbox ?
From toolbar "Drawing" or from toolbar "Form Controls"?Apollo102 wrote:Sorry then I was wrong. I've always thought about a textshape in a DrawPage. A DrawPage which is included in a writer document. I misunderstood the topic.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: BASIC - Howto handle selected text in a textbox ?
From toolbar "Drawing" . But I'm not the one who has casually asked the question. I just misunderstood the topic.
OpenOffice 4.2 MacOS
Re: BASIC - Howto handle selected text in a textbox ?
so exist no way to control the text selection on AOO ?
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Re: BASIC - Howto handle selected text in a textbox ?
If it happens to be a http://www.openoffice.org/api/docs/comm ... lEdit.html having an interface http://www.openoffice.org/api/docs/comm ... onent.html with method setSelection(aSelection) taking a struct http://www.openoffice.org/api/docs/comm ... ction.html then RPG gave a perfect example in the Basic language.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: BASIC - Howto handle selected text in a textbox ?
Hello
The topic starter does try for a long time to mak macro in BASIC for OOo. I think you cannot understand a lot of the macro examples when you do not under stand how the UNO API is organized
For me the BASIC Programming guide is the best guide.
https://wiki.openoffice.org/wiki/Docume ... ASIC_Guide
https://wiki.openoffice.org/wiki/Docume ... Interfaces
The part about Modules, Services and Interfaces and the following is seen by me always as important.Until the moment I did understand it and knew how to use I did get more progress in understanding. An other part was understanding that an object as a Textcontrol does have different services how to work with that object. A textcontrol does have:
a) A shape
b) The model
c) the view
https://wiki.openoffice.org/wiki/Docume ... With_Forms
Romke
The topic starter does try for a long time to mak macro in BASIC for OOo. I think you cannot understand a lot of the macro examples when you do not under stand how the UNO API is organized
For me the BASIC Programming guide is the best guide.
https://wiki.openoffice.org/wiki/Docume ... ASIC_Guide
https://wiki.openoffice.org/wiki/Docume ... Interfaces
The part about Modules, Services and Interfaces and the following is seen by me always as important.Until the moment I did understand it and knew how to use I did get more progress in understanding. An other part was understanding that an object as a Textcontrol does have different services how to work with that object. A textcontrol does have:
a) A shape
b) The model
c) the view
https://wiki.openoffice.org/wiki/Docume ... With_Forms
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: BASIC - Howto handle selected text in a textbox ?
the RPG example works like a charm. But i want to rescue this thread because want to point the follow:
Now we know how to handle the txt selection, but, how to handle the cursor position ? It has its interesting to be able to edit the cursor position in order to perform a little sub that will predicts the user entry data conforming with stored data.
and also...
exist a way to know what keyboard button is pressed from the RPG event sub ? for example, detect the return key, etc.
thx in advance
Now we know how to handle the txt selection, but, how to handle the cursor position ? It has its interesting to be able to edit the cursor position in order to perform a little sub that will predicts the user entry data conforming with stored data.
and also...
exist a way to know what keyboard button is pressed from the RPG event sub ? for example, detect the return key, etc.
thx in advance
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Re: BASIC - Howto handle selected text in a textbox ?
I bind the key press event of a text box to MRILib.Module1.mri and get the answer to all your questions as soon as I type any char into the box.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: BASIC - Howto handle selected text in a textbox ?
Hello
Did you have study the view of the control you use? Try to understand all the methods, properties and the interfaces belonging to the service what is exported by the object you use.
Romke
Did you have study the view of the control you use? Try to understand all the methods, properties and the interfaces belonging to the service what is exported by the object you use.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: BASIC - Howto handle selected text in a textbox ?
well
the key detect was easy.
sub autoFill(event as object)
if event.KeyCode = 1283 then blabla
anyways, what about the cursor position into a text field ? Can someone point the interface or some help ?
thx in advance
the key detect was easy.
sub autoFill(event as object)
if event.KeyCode = 1283 then blabla
anyways, what about the cursor position into a text field ? Can someone point the interface or some help ?
thx in advance
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Re: BASIC - Howto handle selected text in a textbox ?
Referring to RPGs code above:
min=max. No text range selected. Input cursor at position 3.
Code: Select all
strucselection.min=3
strucselection.max=3
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: BASIC - Howto handle selected text in a textbox ?
no, these parameters passed with the struct handle the text selected, i want to position the cursor, on certain position.
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
Re: BASIC - Howto handle selected text in a textbox ?
Hello
It does not work it that way at least as far I understand it.
Romke
It does not work it that way at least as far I understand it.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: BASIC - Howto handle selected text in a textbox ?
Hello
I did look again to those things I knew from text in a textbox in a form. As far I knew you want work with the complete textbox and it is not easy to modify some part of the textbox text.
There is an interface xsimpletext for the model and also the view of the control export some methods and properties. When we want work with the text in the control and maybe also with the other part of the form document then we have to set a special property: Hide selection.
When you want show the selection always then it must be set to no.
I assume we want seen what we do on the screen. As far I understand we have to work with the view of the control and not the model.
Apollo102 give some code and that code does not work in the way he expect but that code can be used when you use the xsimpletext. I can work with xsimpletext but we do not see anything on screen.
What means this all: it is real difficult to work with the text in a textbox and show it on screen. You need knowledge about several interfaces and those interfaces seems not work together as far I understand.
Xsimpletext is:
http://www.openoffice.org/api/docs/comm ... eText.html
What export:
http://www.openoffice.org/api/docs/comm ... ursor.html
Romke
I did look again to those things I knew from text in a textbox in a form. As far I knew you want work with the complete textbox and it is not easy to modify some part of the textbox text.
There is an interface xsimpletext for the model and also the view of the control export some methods and properties. When we want work with the text in the control and maybe also with the other part of the form document then we have to set a special property: Hide selection.
When you want show the selection always then it must be set to no.
I assume we want seen what we do on the screen. As far I understand we have to work with the view of the control and not the model.
Apollo102 give some code and that code does not work in the way he expect but that code can be used when you use the xsimpletext. I can work with xsimpletext but we do not see anything on screen.
What means this all: it is real difficult to work with the text in a textbox and show it on screen. You need knowledge about several interfaces and those interfaces seems not work together as far I understand.
Xsimpletext is:
http://www.openoffice.org/api/docs/comm ... eText.html
What export:
http://www.openoffice.org/api/docs/comm ... ursor.html
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: BASIC - Howto handle selected text in a textbox ?
Hello
For you information:
You read and write the min and the max of the selection.
Romke
For you information:
You read and write the min and the max of the selection.
Code: Select all
print oTextboxControl.selection.max
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: BASIC - Howto handle selected text in a textbox ?
It is just as Villeroy says, a cursor position is a textrange which has its end on the same position as its beginning. See the attached example. The cursor in a textfield is somewhat different than the regular viewcursor, as you can only select one contiguous part of the text. Furthermore this only works with unformatted textfields, please see my question in the forum viewtopic.php?f=20&t=71091.Villeroy wrote:Referring to RPGs code above:min=max. No text range selected. Input cursor at position 3.Code: Select all
strucselection.min=3 strucselection.max=3
eibo
- Attachments
-
- SelectInTextfield.odt
- (12.77 KiB) Downloaded 335 times
AOO 4.0 on Debian Wheezy
Re: BASIC - Howto handle selected text in a textbox ?
Hello Eibo
I have the idea you can better search for an other solution.
Romke
I have the idea you can better search for an other solution.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2