OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

actionPerformed method for button on impress page

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
chris2008
General User
General User


Joined: 25 Aug 2008
Posts: 5

PostPosted: Mon Sep 22, 2008 12:39 pm    Post subject: actionPerformed method for button on impress page Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group