chris2008 General User

Joined: 25 Aug 2008 Posts: 5
|
Posted: Mon Sep 22, 2008 12:39 pm Post subject: actionPerformed method for button on impress page |
|
|
Hi,
I'm trying to implement an action performed method for a button. I found several simple examples but they all did not work. Only ones I got a reaction and never again after that which I don't know the reason for...
That's my code:
| Code: |
Dim oShape As Object
Dim aPosition as new com.sun.star.awt.Point
Dim aSize as new com.sun.star.awt.Size
'creating a CommandButton
button = thisComponent.createInstance("com.sun.star.form.component.CommandButton")
buttonEventListener = createUnoListener("buttonClicked_", "com.sun.star.awt.XEventListener")
button.addEventListener(buttonEventListener)
'creating a ControlShapes for the button
oShape = thisComponent.createInstance("com.sun.star.drawing.ControlShape")
aPosition.x = 13000
aPosition.y = 18000
aSize.width = 1500
aSize.height = 1500
oShape.Position = aPosition
oShape.Size = aSize
oShape.Control = button
'creating a Form, adding the button to it
oForm = thisComponent.createInstance("com.sun.star.form.component.Form")
oForm.Name = "form_Button"
oForm.insertByIndex(0, button)
'adding Form and ControlShape to page
oPage = thisComponent.getCurrentController().getCurrentPage()
oPage.Forms.insertByIndex(0, oForm)
oPage.add(oShape)
Sub buttonClicked_eventPerformed(event As Object)
MsgBox("EVENT performed")
End Sub
|
I also found one example using XActionListener and button.addActionListener() but found out that CommandButton does not have a method addActionListener... Why does that work for someone else?
Why does that code not work for me? Did I forget something? Or is there a problem in adding the button to the page?
Greetings,
Chris |
|