Hi Carsten, Thank you very much for your advice. I followed the links you provided and tried to run the example, but I failed. My steps are below.
I read the chapters on Jobs of the developer guide. Then I tried the example JobsAddon provided by SDK. The path is OpenOffice.org_2.4_SDK\examples\DevelopersGuide\Components\Addons\JobsAddon There are three files in this example: Addons.xcu, AsyncJob.java, Jobs.xcu. I created a simple OpenOffice.org Add-on using the OpenOffice plugin for NetBeans, we call it NewAddon. Then I did the following: 1, copied the configuration code in Addons.xcu of JobsAddon to Addons.xcu of NewAddon. 2, copied the file Jobs.xcu to the project NewAddon 3, extended XAsyncJob interface in NewAddon and copy the code in executeAsync() to the same method in NewAddon. After building successfully, I made a breakpoint in executeAsync() and tried to debug the NewAddon. But executeAsync() was never called. I am afraid I am not using Jobs correctly. Would you please share me some examples or give me more advice? Thank you very much. Carsten Driesner wrote: > > wheelsdong wrote: >> Hi, >> I am trying to create a simple OO Add-On supporting context menu, mouse >> click and menu command. >> I created an simple OpenOffice.org Add-on using the OpenOffice plugin for >> NetBeans. >> And I implemented two interfaces: com.sun.star.ui.XContextMenuInterceptor >> and com.sun.star.awt.XMouseClickHandler. >> The ContextMenuInterceptor and MouseClickHandler are registered in >> initialize() function. >> >> However, The problem is: >> 1, When I clicked the right mouse button, initialize() will be called, so >> ContextMenuInterceptor and MouseClickHandler are registered more than one >> time. >> So If a left mouse button is pressed and released, the mouseReleased >> function will be called many times. >> 2, The first time I click the newly added menu title, initialize() will >> also >> be called. >> >> My question is: >> Since initialize() may be called many times. Where should I register >> ContextMenuInterceptor and MouseClickHandler so that they are called only >> once? >> >> Thank you very much for your help. >> >> Below are some code for your reference: >> > > Hi wheelsdong, > > You should use a job and register for "OnViewCreated" events which call > your code once for every new frame. You can find more information about > Jobs in the online wiki: > > http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Jobs/Jobs > > Regards, > Carsten > > -- View this message in context: http://www.nabble.com/Where-to-register-MouseClickHandler-in-an-Add-On--tp20221786p20260528.html Sent from the openoffice - api dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
