To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=76767
------- Additional comments from [EMAIL PROTECTED] Thu May 10 17:54:58 +0000
2007 -------
Of course it works because you created a window from scratch, but I'd like to
use a window of Draw.
The following piece of code does not work with Draw.
The methods mouseMoved and mouseDragged are never called.
Did try my code ? From the menu Tools -> Manage extension add the zip file
attached and then open a new draw file, you will see a new menu title
"TestComp".
try:
import uno, unohelper
from com.sun.star.task import XJob
import traceback
from com.sun.star.awt import XMouseMotionListener, XKeyHandler,
XMouseClickHandler
except ImportError:
print "probleme d'import"
#===================================
# a class to test listener
# une classe pour tester un listener
#===================================
class CompJob(unohelper.Base, XJob, XMouseMotionListener, XKeyHandler,
XMouseClickHandler):
"""Test de listener
Test of listener"""
def __init__(self, ctx):
self.ctx = ctx
self.smgr = self.ctx.ServiceManager
# get the central desktop object
self.desktop = self.smgr.createInstanceWithContext(
"com.sun.star.frame.Desktop",self.ctx)
## *********************
## this method is called from an other one trigged by a command from menu
## *********************
def execute(self, aArgs):
# access the current draw document
if self.desktop.ActiveFrame.ActiveFrame:
self.COMPONENTWINDOW =
self.desktop.ActiveFrame.ActiveFrame.ComponentWindow
self.CONTROLLER = self.desktop.ActiveFrame.ActiveFrame.Controller
else:
self.COMPONENTWINDOW = self.desktop.ActiveFrame.ComponentWindow
self.CONTROLLER = self.desktop.ActiveFrame.Controller
self.CONTROLLER.addKeyHandler(self)
self.COMPONENTWINDOW.addMouseMotionListener(self)
self.CONTROLLER.addMouseClickHandler(self)
return aArgs
#*********************
# test of mouse motion
#*********************
def mouseMoved(self, aMouseEvent):
print "mouse motion"
return
# **********************************
def mouseDragged(self, aMouseEvent):
print "mouse dragged"
return
# **********************************
def mousePressed(self, aMouseEvent):
print "mouse pressed"
return True
# **********************************
def mouseReleased(self, aMouseEvent):
print "mouse released"
return True
# **********************************
def keyPressed(self, aKeyEvent):
print "key pressed"
return True
# **********************************
def keyReleased(self, aKeyEvent):
print "key released, bye !"
self.CONTROLLER.removeKeyHandler(self)
self.COMPONENTWINDOW.removeMouseMotionListener(self)
self.CONTROLLER.removeMouseClickHandler(self)
return True
# XEventListener
def disposing(self, eventObject):
return
# pythonloader looks for a static g_ImplementationHelper variable
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(CompJob,
# UNO object class
"org.openoffice.comp.pyuno.deneux.CompJob", # implemenation name
("org.openoffice.comp.pyuno.CompJob",),) # list of implemented services
---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]