Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index

Hi Paolo

If I understand this correctly you have created a dialog that contains a button that you want to give dropdown-functionality. The Main method starts the dialog and when the button is pressed it calls the sub PopupButton that creates the popup button and sets up the XMenuListener and a couple of subs that are used by the listener.

If you look at the api docs and search for XMenuListener you'll find:

There you'll find out that the memberfunctions for this listener is not the same as the ones you used. I actually think this is true for newer versions of Apache OpenOffice as well, but that is a side note and I haven't looked into this to deeply.

This means that you need to adapt the names of last five subs from
PopupMenuListener_select -> PopupMenuListener_itemSelected
PopupMenuListener_highlight -> PopupMenuListener_itemHighlighted
PopupMenuListener_activate -> PopupMenuListener_itemActivated
PopupMenuListener_deactivate -> PopupMenuListener_itemDeactivated
PopupMenuListener_disposing -> PopupMenuListener_disposing

OK the last one did not need any adaption. ;)

A quick tip if you create a uno listener is to inspect it with xray to find out what methods (subs) you need to create. Let us know if you need more guidance.

Niklas Johansson

Paolo Ferrario skrev 2014-11-10 07:47:
Hello everybody

We are moving from OpenOffice to LibreOffice

We have some macros that uses popup menus that work perfectly in
OpenOffice but they don't work in LibreOffice.

We developed our code starting from examples (thanks Hania and Ermione)
that we found over the internet and that are attached.

Any suggestions to make the macro run fine?
Thanks to everybody

REM  *****  BASIC  *****

Dim oDialog As Object

Dim oPopupMenu As Object

Sub Main

   sLibName = "Standard"

   sDialogName = "Dialog1"


   ' create new dialog

   oDialog = CreateUnoDialog( _



End Sub

Sub PopupButton

   ' get the size of the button

   oButton = oDialog.getControl("CommandButton1")

   aPosSize = oButton.PosSize

   ' set the position of the popup menu

   Dim aRect As New

   With aRect

     .X = aPosSize.X

     .Y = aPosSize.Y + aPosSize.Height

     .Width = 0'100

     .Height = 0'100

   End With

   ' menu listener

   oMenuListener = CreateUnoListener( _

     "PopupMenuListener_", "")

   ' new popupmenu

   oPopupMenu = CreateUnoService("")

   ' set listener and insert menu items

   With oPopupMenu


     .insertItem(1,"Menu 1",0,0) 'id, label, type, position

     .insertItem(2,"Menu 2",0,2)




   End With

   ' show popup menu

   oPopupMenu.execute(oDialog.Peer,aRect, _


End Sub

Sub PopupMenuListener_select ( oEv )

   sCmd = oEv.Source.getCommand(oEv.MenuId)

   msgbox sCmd

End Sub

Sub PopupMenuListener_highlight ( oEv )

End Sub

Sub PopupMenuListener_activate ( oEv )

End Sub

Sub PopupMenuListener_deactivate ( oEv )

End Sub

Sub PopupMenuListener_disposing( oEv )

End Sub


Ferrario Luigi s.r.l.
Ing. Paolo Ferrario
Viale Edison 629
20099 Sesto S. Giovanni
Tel: +
Fax: +

The information transmitted is intended only for the person or entity to
it is addressed and may contain confidential and/or privileged material.
review, retransmission, dissemination or other use of, or taking of any
in reliance upon, this information by persons or entities other than the
intended recipient is prohibited. If you received this in error, please
contact the sender and delete the material from any computer.

To unsubscribe e-mail to:
Posting guidelines + more:
List archive:
All messages sent to this list will be publicly archived and cannot be deleted


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.