 | OO-Snippets: set event dynamicallyCommons| Keywords | Button, Event, Dynamic, Persistant |
|---|
| Language | OOBasic |
|---|
| Application | Office |
|---|
| Authors | Oliver Brinzing (initial)
Laurent Godard Tom Schindl
|
|---|
| Supported Versions | |
|---|
| Supported OS | |
|---|
| Question |
I have a lot of controls (250 buttons) in a document and want to set their "when intiating" events dynamically
I want to do this only once on building the document so that, when the document is reloaded the events are still there.
(like if i do it manually with right click on the control and assign manually)
|
|---|
| Answer |
thanks to Oliver Brinzing
More than one vent can be registered even if the UI in design mode shows the last one |
|---|
Option Explicit
Sub SetEvent
Dim oDocument as Object
Dim oView as Object
Dim oDrawPage as Object
Dim oForm as Object
Dim oEvents(0) as New com.sun.star.script.ScriptEventDescriptor
oDocument = StarDesktop.getCurrentComponent
oView = oDocument.CurrentController
oDrawPage = oView.getActiveSheet.DrawPage
oForm = oDrawPage.getForms.getByIndex(0)
oEvents(0).ListenerType = "XActionListener"
oEvents(0).EventMethod = "actionPerformed"
oEvents(0).AddListenerParam = ""
oEvents(0).ScriptType = "StarBasic"
oEvents(0).ScriptCode = "document:Standard.Module1.Test"
oForm.registerScriptEvent(0, oEvents(0))
End Sub
Sub Test(oEvt)
Print oEvt.Source.Model.Name
End Sub
|
Changelog| Date | User | Modification |
|---|
| 2004-06-22 | tomsontom | Modified to match new snippet-DTD | | 0000-00-00 | oli | Initial version |
|