thanks for contributing.
I am using OOo 1.9.104 on WinXP (1.9.109 on FedoraCore 3), but I don't seem to be able to create a Python script from the OOo GUI. _javascript_ and Beanshell is working, but not Python. Is this a bug? Also I am very interested to know, what XSCRIPTCONTEXT really is, is this a global variable like thisComponent is for SB? Never seen it before.
2005/6/16, Leston Buell <[EMAIL PROTECTED]>:
Thank you for the help, Joerg. With your help i got a minimal macro
working, which i am posting here for anyone searching the mailing list
later looking for help on this.
Leston
------------------------------------------
import unohelper
from com.sun.star.awt import XKeyHandler
# Note that XSCRIPTCONTEXT will only be available
# when you run Python as an OOo macro.
oDesktop = XSCRIPTCONTEXT.getDesktop()
class MyKeyHandler( unohelper.Base, XKeyHandler ) :
def keyPressed( self, oEvent ) :
print "Key pressed."
return False
def keyReleased( self, oEvent ) :
print "Key released."
return False
def disposing( self, source ) :
pass
theKeyHandler = MyKeyHandler( )
def attach() :
currentComponent = oDesktop.getCurrentComponent ()
currentController = currentComponent.getCurrentController()
currentController.addKeyHandler( theKeyHandler )
print "theKeyHandler attached."
def detach() :
currentComponent = oDesktop.getCurrentComponent()
currentController = currentComponent.getCurrentController()
currentController.removeKeyHandler( theKeyHandler )
print "theKeyHandler detached."
g_exportedScripts = attach, detach,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Best Regards
Christian Junker
