OOo dialog : How to set focus on individual widget ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

OOo dialog : How to set focus on individual widget ?

Manuel Odesser
Hello,

In a dialog I am displaying from a OOBasic script, I'd like to move the
focus on different widgets, using the keyboard arrows. More
specifically, I have two ListBox side-by-side. The one on the left
contains topics, the one on the right is filled dynamicly with relevant
articles, according to the selected topic. The goal here is to use the
keyboard to select a topic and then an article.

I found this thread
http://www.oooforum.org/forum/viewtopic.phtml?t=32743#130869, that
mentions a setFocus() method. Unfortunately, it only applies to
::com::sun::star::awt::XWindow. Is there a way to programmaticaly shift
focus on an arbitray dialog control ?
<http://api.openoffice.org/docs/common/ref/com/sun/star/awt/XWindow.html>

Thank you
<http://api.openoffice.org/docs/common/ref/com/sun/star/awt/XWindow.html>

--
Manuel Odesser

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: OOo dialog : How to set focus on individual widget ?

Stephan Wunderlich - Sun Germany - ham02 - Hamburg
Hi Manuel,

> In a dialog I am displaying from a OOBasic script, I'd like to move the
> focus on different widgets, using the keyboard arrows. More
> specifically, I have two ListBox side-by-side. The one on the left
> contains topics, the one on the right is filled dynamicly with relevant
> articles, according to the selected topic. The goal here is to use the
> keyboard to select a topic and then an article.
>
> I found this thread
> http://www.oooforum.org/forum/viewtopic.phtml?t=32743#130869, that
> mentions a setFocus() method. Unfortunately, it only applies to
> ::com::sun::star::awt::XWindow. Is there a way to programmaticaly shift
> focus on an arbitray dialog control ?
> <http://api.openoffice.org/docs/common/ref/com/sun/star/awt/XWindow.html>
>
> Thank you
> <http://api.openoffice.org/docs/common/ref/com/sun/star/awt/XWindow.html>

The listbox is a css.awt.UnoListBox (
http://api.openoffice.org/docs/common/ref/com/sun/star/awt/UnoControlListBox.html 
  ) which includes the service css.awt.UnoControl (
http://api.openoffice.org/docs/common/ref/com/sun/star/awt/UnoControl.html 
).

The latter exports css.awt.XWindow ... so the method getFocus() should
be available at every control.

Regards

Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: OOo dialog : How to set focus on individual widget ?

Manuel Odesser
> Hi Manuel,
>
>> In a dialog I am displaying from a OOBasic script, I'd like to move the
>> focus on different widgets, using the keyboard arrows. More
>> specifically, I have two ListBox side-by-side. The one on the left
>> contains topics, the one on the right is filled dynamicly with relevant
>> articles, according to the selected topic. The goal here is to use the
>> keyboard to select a topic and then an article.
>>
[...]

>> <http://api.openoffice.org/docs/common/ref/com/sun/star/awt/XWindow.html>
>
> The listbox is a css.awt.UnoListBox (
> http://api.openoffice.org/docs/common/ref/com/sun/star/awt/UnoControlListBox.html
>   ) which includes the service css.awt.UnoControl (
> http://api.openoffice.org/docs/common/ref/com/sun/star/awt/UnoControl.html
> ).
>
> The latter exports css.awt.XWindow ... so the method getFocus() should
> be available at every control.

Hello,

Thank you ! I was using oDialog.getByName("Termes").setFocus() instead of
oDialog.getControl("Termes").setFocus(). I can now focus where I want to.

However, I still have a problem. On which event should I bind the
following macro to get the job done : onKeyPress or onKeyReleased ? Both ?
  Based on actual widget selected content, I'd like to update another
widget content before moving focus.

Sub KeyPressedInDialog(Event As Object)
     Dim widget As String
     Dim control As Object
     widget = Event.Source.Model.Name
     Select Case widget
         Case "Domaines"
             Select Case Event.KeyCode
                 Case com.sun.star.awt.Key.RIGHT
                     UpdateSelectedTerm
                     Set control = oDialog.getControl("Termes")
                     control.setFocus()
                 Case com.sun.star.awt.Key.DOWN
                 Case com.sun.star.awt.Key.UP
                     UpdateTermsList
             End Select
         Case "Termes"
             Select Case Event.KeyCode
                 Case com.sun.star.awt.Key.LEFT
                     Set control = oDialog.getControl("Domaines")
                     control.setFocus()
                 Case com.sun.star.awt.Key.DOWN
                 Case com.sun.star.awt.Key.UP
                     UpdateSelectedTerm
             End Select
         Case "remplacement"
             Select Case Event.KeyCode
                 Case com.sun.star.awt.Key.RETURN
                     ReplaceAnglicisme
             End Select
     End Select
End Sub

Any idea ?


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]