| View previous topic :: View next topic |
| Author |
Message |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Mon Mar 29, 2004 7:33 am Post subject: MouseListener |
|
|
Hello everybody, I am currently searching for information about using an EventListener, in particular a MouseListener.
It should just work simply, giving back the position of where an user has left-clicked on the active window (later this x and y postion components will be assigned for a drawing object).
The Interface XMouseListener is used in a special "XWindow" which can exist in Presentation Slide View but also in Drawing View of sdraw. We want to use the sdraw domain, but the only thing we have worked out yet is how to create an EventListener with the UNO command line:
| Code: |
olistener = CreateUnoListener("MouseListener_", "com.sun.star.awt.XMouseListener")
|
This is just a suggestion how to get work with the mouse_clicked Event, if anybody out there knows another method which leads to the same goal, getting the x and y position out of the Mouseclick on the active window, then please answer.
TIA Christian
*update*
I have found that I probably hit one of the bigger still missing subjects (flaw) in the API. I hope that the SDK developers will fix the problem in the near future, so that mouse click events can be responded to in a window. _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Mon Mar 29, 2004 5:15 pm Post subject: |
|
|
after everlasting minutes of search I found that the MouseHandler must be defined, so it's working!
Despite that I would really appreciate a better and preciser documentation about EventListeners, ~Handlers and ~Broadcasters.
But anyway everything is fine now  _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
dysmas Power User

Joined: 14 Apr 2007 Posts: 59 Location: Grenoble, France
|
Posted: Tue Jan 01, 2008 9:16 am Post subject: |
|
|
Hello, I found the code in Andrew's Macro, and it is working fine.
| Code: | Sub RegisterMouseClickHandler
oDocView = ThisComponent.currentController
oMouseClickHandler = _
createUnoListener("MyApp_", "com.sun.star.awt.XMouseClickHandler")
' writedbginfo oMouseClickHandler
oDocView.addMouseClickHandler(oMouseClickHandler)
End Sub |
But I am looking for something different : I am interested in drags on the active document, and there is no XMouseMotionHandler, and probably it would not make sense because only a listener can "follow" the mouse, I guess. I tried with XMouseMotionListener, but until now I was unable to have it work. It works inside a window I create, but not on the active document. _________________ Dysmas |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
dysmas Power User

Joined: 14 Apr 2007 Posts: 59 Location: Grenoble, France
|
Posted: Sun Jan 06, 2008 9:34 am Post subject: |
|
|
Bonjour, Serge, Merci pour la réponse et bonne année. Je continue en anglais pour les autres lecteurs.
I have made systematic tests on :
1) ThisComponent
2) ThisComponent.currentController
3) ThisComponent.currentController.Frame
4) ThisComponent.currentController.Frame.containerWindow
5) ThisComponent.currentController.ViewCursor
with :
A) oDocView.addMouseClickHandler(oMouseClickHandler)
B) oDocView.addMouseMotionListener(oMouseMotion)
The only working combinations are : A2 and B4
All other combinations send a : "property or method not found" message.
This is confirmed by Xray and the API documentation.
KeyListener, MouseListener, MouseMotionListener are functions of XWindow
I found that they work with : Windows and form objects (I tried with button, label, EditBox)
A2 (see Andrew's code above) works perfectly.
B4 (code below) does not send an error message, but until now I got nothing of it. The associated MyApp2_.... functions are never fired.
Code is :
| Code: | Sub RegisterMouseMotionListener3
oDocView = ThisComponent.currentController.Frame.containerWindow
oMouseMotion = _
createUnoListener("MyApp2_", "com.sun.star.awt.XMouseMotionListener")
oDocView.addMouseMotionListener(oMouseMotion)
End Sub |
See the following of the story in : http://www.oooforum.org/forum/viewtopic.phtml?t=67357 _________________ Dysmas |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
|
| Back to top |
|
 |
dysmas Power User

Joined: 14 Apr 2007 Posts: 59 Location: Grenoble, France
|
Posted: Tue Jan 08, 2008 3:19 am Post subject: |
|
|
Thanks for this reference. Although it is bad news, since it means that what I am trying to do is not yet possible.
The message of Carsten Driesner ends with :
| Quote: | >> - Is there a possibility to get refferences to all child windows of
>> a given parent window?
This is not possible as there is no UNO AWT interface that would provide
access to child windows. Please write a request for enhancement to me. |
I wonder if there is anything to do here ? Is there a standard form for such requests, or a mail to his address will do ? _________________ Dysmas |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Tue Jan 08, 2008 9:47 am Post subject: |
|
|
Hi,
the procedure is to register, file an enhancement request, and advertise so that as many as possible users vote for your enhancement request. See http://qa.openoffice.org/ooQAReloaded/ooQA-ReportBugs.html .
I would not be too optimistic about that, though. There is a huge number of open requests with lots of votes ...
If you give more details about what you want to achieve as an application, we could try to find some ugly workarounds
ms777 |
|
| Back to top |
|
 |
dysmas Power User

Joined: 14 Apr 2007 Posts: 59 Location: Grenoble, France
|
Posted: Sat Mar 15, 2008 2:19 am Post subject: |
|
|
Hi, ms777
more than 2 months has passed, and I have not yet repied. The reason was I wanted to develop a little more the planned extension before sending you something, but time passes and things don't move. Now I learned that Sun has started an OpenOffice.org Community Innovation Program and I thought it would be an occasion to get the attention of developers on this extension which I would like to see integrated in OO one day. I think this is useful new concept, which would give OO Writer an improvement.
I just opened a thread which describes the whole thing :
http://www.oooforum.org/forum/viewtopic.phtml?p=277800
And you can find a working model at the following addess :
http://rapidshare.com/files/100197680/swissknife0.1.1.oxt
(click on free, you don't have to pay for an account)
The drag function is only a proof of concept and works only with spacing above paragraph. Drag is highly buggy : already found two serious bugs. _________________ Dysmas |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
|
| Back to top |
|
 |
dysmas Power User

Joined: 14 Apr 2007 Posts: 59 Location: Grenoble, France
|
Posted: Mon Apr 06, 2009 3:57 am Post subject: |
|
|
Thanks a lot. I will surely play with your code, although I am not sure if I will continue to develop the tool I was working on last year, but this for a good reason :
I submitted my work to the code contest, last year and I won a prize. This means that OO developpers were interested by my idea and we may hope that one day it will be included in OO. This was my main purpose : making this tool available for all users. The prize was the last category, so it will surely not be a priority, but let us hope.
Anyway, perhaps that with drag I can offer a working extension. We will see.
But thanks a lot for your help which has been really valuable all the time.
Sincerely _________________ Dysmas |
|
| Back to top |
|
 |
|