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

how do I get which form's text field has keyboard focus?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
LukenShiro
Newbie
Newbie


Joined: 09 Jul 2006
Posts: 3

PostPosted: Mon Jul 10, 2006 2:35 am    Post subject: how do I get which form's text field has keyboard focus? Reply with quote

Greetings to all Wink

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
View user's profile Send private message
Peter
OOo Enthusiast
OOo Enthusiast


Joined: 28 May 2004
Posts: 105
Location: Berlin / Germany

PostPosted: Mon Jul 10, 2006 10:44 pm    Post subject: Reply with quote

Did you try a listener?
http://api.openoffice.org/docs/common/ref/com/sun/star/awt/XFocusListener.html

Regards

Peter
Back to top
View user's profile Send private message
Peter
OOo Enthusiast
OOo Enthusiast


Joined: 28 May 2004
Posts: 105
Location: Berlin / Germany

PostPosted: Mon Jul 10, 2006 11:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
LukenShiro
Newbie
Newbie


Joined: 09 Jul 2006
Posts: 3

PostPosted: Tue Jul 11, 2006 12:04 am    Post subject: Reply with quote

Uhm, thank you Peter!!
I will try that as soon as possible Smile
Regards.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org 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