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]

Reply via email to