| View previous topic :: View next topic |
| Author |
Message |
LukenShiro Newbie

Joined: 09 Jul 2006 Posts: 3
|
Posted: Mon Jul 10, 2006 2:35 am Post subject: how do I get which form's text field has keyboard focus? |
|
|
Greetings to all
I am fairly a new OO-Basic user, I'm working on a OOo 2.0 writer form document. This form has several text fields and some buttons (from which a user inserts some values in a database table).
I've read some posts here but I don't understand how can I know (in a Basic Function) which field has the keyboard focus now?
In Staroffice 8 programming guide I've read that getfocus() appears to be only for dialog windows, is there a method "getfocus()", maybe similar to setfocus() as in this chunk of basic code, and how works?
| Code: |
oCampo=oForm.getByName("NomeCampo")
ctlView=oDoc.getCurrentController().getControl(oCampo)
ctlView.setFocus()
|
Or do I have to use AccessibleStateType.FOCUSED
(BTW I've read, in Andrew Pitonyak's Macro Document, accessible context's topic, but I don't really know if these methods can be used also for find focused text field, or I'm completely mistaken and out of road ...) ?
Thank you in advance. |
|
| Back to top |
|
 |
Peter OOo Enthusiast

Joined: 28 May 2004 Posts: 105 Location: Berlin / Germany
|
|
| Back to top |
|
 |
Peter OOo Enthusiast

Joined: 28 May 2004 Posts: 105 Location: Berlin / Germany
|
Posted: Mon Jul 10, 2006 11:38 pm Post subject: |
|
|
The following should work (not tested). Introspecting e you should get the corresponding control.
| Code: |
private xList
Sub Main
xList = CreateUNOListener("XL_","com.sun.star.awt.XFocusListener")
For i = 0 to ThisComponent.DrawPage.Forms(0).Count - 1
oControl = ThisComponent.CurrentController.GetControl(ThisComponent.DrawPage.Forms(0).GetByIndex(i))
oControl.AddFocusListener(xList)
next
End Sub
Function XL_focusGained(e)
msgBox "gained"
End Function
Function XL_focusLost(e)
msgBox "lost"
End Function |
|
|
| Back to top |
|
 |
LukenShiro Newbie

Joined: 09 Jul 2006 Posts: 3
|
Posted: Tue Jul 11, 2006 12:04 am Post subject: |
|
|
Uhm, thank you Peter!!
I will try that as soon as possible
Regards. |
|
| Back to top |
|
 |
|