[EMAIL PROTECTED] wrote:
How? Does anyone have an example that sets accelerators?
Hi Jorge,
here is a little Basic example on how to set accelerators.
REM ***** BASIC *****
REM *** Example to set a keyboard shortcut with the new ui
configuration API
Sub Main
REM *** Initialize constants. See IDL file
REM com.sun.star.awt.KeyEvent
REM com.sun.star.awt.KeyModifier
REM com.sun.star.awt.Key
MODIFIER_SHIFT = 1
MODIFIER_MOD1 = 2
MODIFIER_MOD2 = 4
KEY_F10 = 777
REM *** Retrieve the global accelerator configuration manager
oGlobalAccelCfgMgr =
createUnoService("com.sun.star.ui.GlobalAcceleratorConfiguration")
REM *** Retrieve the module configuration manager from central module
configuration manager supplier
oModuleCfgMgrSupplier =
createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
REM *** Retrieve the module configuration manager with module identifier
REM *** See com.sun.star.frame.ModuleManager for more information
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager(
"com.sun.star.text.TextDocument" )
REM *** Retrieve the writer accelerator configuration manager
oWriterAccelCfgmgr = oModuleCfgMgr.getShortCutManager()
REM *** Define short cut key event for our macro
Dim aKeyEvent as new com.sun.star.awt.KeyEvent
aKeyEvent.Modifiers = MODIFIER_SHIFT
aKeyEvent.KeyCode = KEY_F10
REM *** Set our short cut at the Writer accelerator manager
oWriterAccelCfgMgr.setKeyEvent( aKeyEvent,
"macro:///Standard.Module1.Test" )
oWriterAccelCfgMgr.store()
End Sub
Sub Test
MsgBox( "Test" )
End Sub
Regards,
Carsten
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]