Hi Cor,
Cor Nouws escribió:
Hi,
Another problem.
I want to know if Tab is pressed and then do some stuff. (Basically I
want to prevent that Tab adds another row at a table).
Simple code as shown below, does work. However, I seem to miss some things.
a. It only works for one time pressing Tab. The listener seems to be
stopped then
sounds strange. I'll have to test it (could it be that OOo Basic is too
slow reacting? mmm I doubt it... or may be the way the handler consumes
the event? The best would be using C++ or Java and printing in stdout
every time the listener's methods are called - I'll give it a try)
b. First I tried com.sun.star.awt.XKeyListener, but addKeyListener seems
not to be a method of oView, and I can't see any info why.
you have two different interfaces:
com.sun.star.awt.XKeyHandler
com.sun.star.awt.XKeyListener
The difference is that the handler consumes the event.
For adding a key handler, you must use the method addKeyHandler() from
the interface XUserInputInterception. This interface is implemented by
the controller css.frame.Controller (of all office documents except OOo
Base). In Basic
ThisComponent.getCurrentController().addKeyHandler()
For adding a key listener, you must use the method addKeyListener() from
the interface css.awt.XWindow. In Basic
ThisComponent.getCurrentController().getFrame().getContainerWindow().addKeyListener()
[I'm not sure if this will also work (and how) with the component window
- in case there is one (as some modules have no component window, for
example the DataSourceBrowser):
ThisComponent.getCurrentController().getFrame().getComponentWindow().addKeyListener()]
Be aware that if you choose to use the key handler, the controller may
get disposed, but the document may still be opened, so your handler
won't be called anymore (for example, if you choose the preview, the
controller is disposed when the component is detached from the frame to
create the new view of the document in the pre-view).
You can work around this with a frame action listener, as discussed in
my endless mail
http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=21148 (but see
Carsten's comments for precisions/corrections:
http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=21243 )
Regards
Ariel.
--
Ariel Constenla-Haile
La Plata, Argentina
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.ArielConstenlaHaile.com.ar/ooo/
"Aus der Kriegsschule des Lebens
- Was mich nicht umbringt,
macht mich härter."
Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]