A Menubar button with a popup menu is (I understand) possible with an xtoolbarcontroller but that can't be implemented with the OOBasic language.
Making a popup menu show when a menubar button is clicked is easy but a workaround is needed to:
- get it positioned
- so the menu shows when the button is pressed rather than clicked
- so a menu item can be selected with the mouse still held down
See attached demo for menu example.
A dropdown using a dialog could be accomplished in the same way.
(note only tested in OpenOffice)
'UPDATES
'14 01 20: added missed sub THANKS TO musikai
Menubar button with popup menu or dropdown in OOBasic
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This section is not for asking questions about writing your own macros.
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This section is not for asking questions about writing your own macros.
Menubar button with popup menu or dropdown in OOBasic
- Attachments
-
- Toolbar Button PopUp.odt
- (18.18 KiB) Downloaded 347 times
Last edited by JeJe on Wed Jan 15, 2020 12:36 am, edited 1 time in total.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Menubar button with popup menu or dropdown in OOBasic
This is cool!!! Works also in LibreOffice. (This could tidy up my long list of Toolbar buttons in a nice way. Also the possibility of having separators is great!)
only when running
I get an error saying
isn't found
Good that you provided the link to hanya's findtoolbar in the code
viewtopic.php?f=20&t=56336
and there is the missing function:
Is there a list of the different style possibilities by the PValue ?
I like the look of PValue=256 with the dropdown arrow but this doesn't seem to be compatible here. (pressing the button will show the menu but not pressing the arrow)
only when running
Code: Select all
SetToolbarItemRepeat
Code: Select all
GetPropertyValueByName
Good that you provided the link to hanya's findtoolbar in the code
viewtopic.php?f=20&t=56336
and there is the missing function:
Code: Select all
Function GetPropertyValueByName(aElements, sName) As Variant
found = nothing
for i = 0 to ubound(aElements) step 1
if aElements(i).Name = sName then
found = aElements(i).Value
end if
next
GetPropertyValueByName = found
End Function
I like the look of PValue=256 with the dropdown arrow but this doesn't seem to be compatible here. (pressing the button will show the menu but not pressing the arrow)
Win7 Pro, Lubuntu 15.10, LO 4.4.7, OO 4.1.3
Free Project: LibreOffice Songbook Architect (LOSA)
http://struckkai.blogspot.de/2015/04/li ... itect.html
Free Project: LibreOffice Songbook Architect (LOSA)
http://struckkai.blogspot.de/2015/04/li ... itect.html
Re: Menubar button with popup menu or dropdown in OOBasic
Thanks... that's wierd I didn't get the error... added to document. I originally wrote it without using those functions and I may revert to that if I do a rewrite.
The itemstyle constants are here:
https://www.openoffice.org/api/docs/com ... Style.html
The dropdown arrow will show but it needs xtoolbarcontroller to implement that... which we can't do with basic.
The useful ones seem to be
- setting the menu item to show text or icon or both text and icon
- setting repeat, which you may want to use for a normal button as well
You can't set either of these without using a macro to do it in OO.
The itemstyle constants are here:
https://www.openoffice.org/api/docs/com ... Style.html
The dropdown arrow will show but it needs xtoolbarcontroller to implement that... which we can't do with basic.
The useful ones seem to be
- setting the menu item to show text or icon or both text and icon
- setting repeat, which you may want to use for a normal button as well
You can't set either of these without using a macro to do it in OO.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)