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

MouseListener

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


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Mon Mar 29, 2004 7:33 am    Post subject: MouseListener Reply with quote

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
View user's profile Send private message Send e-mail
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Mon Mar 29, 2004 9:02 am    Post subject: Reply with quote

I think there is an example in Andrew Pitonyak's document
http://www.pitonyak.org/AndrewMacro.sxw
which is translate in french and german ....
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Mon Mar 29, 2004 5:15 pm    Post subject: Reply with quote

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 Smile
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
dysmas
Power User
Power User


Joined: 14 Apr 2007
Posts: 59
Location: Grenoble, France

PostPosted: Tue Jan 01, 2008 9:16 am    Post subject: Reply with quote

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
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Sat Jan 05, 2008 10:55 am    Post subject: Reply with quote

I think you haven't to use such low level event listeners : use the correct service for your document : use ThisComponent.currentcontroller (or ThisComponent.currentcontroller.ViewCursor if you want a cursor) Xraying is probably a good idea to go further and find for instance if they are corresponding event listeners.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
dysmas
Power User
Power User


Joined: 14 Apr 2007
Posts: 59
Location: Grenoble, France

PostPosted: Sun Jan 06, 2008 9:34 am    Post subject: Reply with quote

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
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Mon Jan 07, 2008 9:22 am    Post subject: Reply with quote

dysmas,

Your skills are more advanced than what I though at first, and certainly more advanced than mine on the subject... Then I cannot help you any more Embarassed
Happy new year.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Mon Jan 07, 2008 12:46 pm    Post subject: Reply with quote

just a crossref: http://www.openoffice.org/servlets/BrowseList?list=dev&by=thread&from=1906597
Back to top
View user's profile Send private message
dysmas
Power User
Power User


Joined: 14 Apr 2007
Posts: 59
Location: Grenoble, France

PostPosted: Tue Jan 08, 2008 3:19 am    Post subject: Reply with quote

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
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Tue Jan 08, 2008 9:47 am    Post subject: Reply with quote

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 Smile

ms777
Back to top
View user's profile Send private message
dysmas
Power User
Power User


Joined: 14 Apr 2007
Posts: 59
Location: Grenoble, France

PostPosted: Sat Mar 15, 2008 2:19 am    Post subject: Reply with quote

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
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Sun Apr 05, 2009 2:01 pm    Post subject: Reply with quote

Hi,

an update concerning adding MouseMotionListener to OO windows is in http://www.oooforum.org/forum/viewtopic.phtml?p=321263#321263 . It is possible ...

Good luck,

ms777
Back to top
View user's profile Send private message
dysmas
Power User
Power User


Joined: 14 Apr 2007
Posts: 59
Location: Grenoble, France

PostPosted: Mon Apr 06, 2009 3:57 am    Post subject: Reply with quote

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
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