Get properties of menu items (Like tooltip of button 'save')

Creating a macro - Writing a Script - Using the API
Post Reply
MiguelTeixeira
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

Get properties of menu items (Like tooltip of button 'save')

Post by MiguelTeixeira »

Is possible to get informations of menu items trought UNO API? I'd like to get a tooltip/HelpText of menu items trought UNO API, using any language. Some idea? I researched a lot about it and found no results. Someone with a way to indicate?

Best regards,
MX Linux, LibreOffice 6
User avatar
robleyd
Moderator
Posts: 4342
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Get properties of menu items (Like tooltip of button 'sa

Post by robleyd »

Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 15 - 64 bit
LibreOffice 6.4.6.2 (SlackBuild for 6.4.6 by Eric Hameleers) - Slackware 15 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
Zizi64
Volunteer
Posts: 10483
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Get properties of menu items (Like tooltip of button 'sa

Post by Zizi64 »

Here is Charlie Young's macro example: how to modify the context menu in the Calc application.

viewtopic.php?f=9&t=36641&p=168101&hili ... ds#p168101

(In my opinion only the Toolbar icons have tooltips, but the menu items have not. )
Tibor Kovacs, Hungary; LO6.1.6, 6.4.7 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.1.1;AOO4.1.9
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
JeJe
Volunteer
Posts: 1964
Joined: Wed Mar 09, 2016 2:40 pm

Re: Get properties of menu items (Like tooltip of button 'sa

Post by JeJe »

That information should be available in the registry. This gets the label of the Save Command but haven't been able to find the Tooltip in OO.

Code: Select all

GlobalScope.BasicLibraries.LoadLibrary("Tools")
c= GetRegistryKeyContent("org.openoffice.Office.UI.GenericCommands") 
msgbox c.getbyname("UserInterface").getbyname("Commands").getbyname(".uno:Save").Label
In LibreOffice you can inspect the registry by going to Tools/Options/Advanced/Open Expert Configuration and search for whatever you want.
Openoffice 4.1.6
Windows 8
MiguelTeixeira
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

Re: Get properties of menu items (Like tooltip of button 'sa

Post by MiguelTeixeira »

Hi,

Thank you very much for your answers!
@JeJe, you know how the stretch:

Code: Select all

"GlobalScope.BasicLibraries.LoadLibrary (" Tools ")"
can be reproduced in Python?

Do you know if there is a way to catch/inspecting the "helptext/tooltip popup" event when it is triggered? Can I inspect this event somewhere? This event occurs exactly when the user places the mouse over an item (like the 'save' button).

I just tested this extension:

https://wiki.openoffice.org/wiki/Object ... ource_code

But it doesn't seem to serve that purpose.

Best Regards,
MX Linux, LibreOffice 6
User avatar
Villeroy
Volunteer
Posts: 30672
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Get properties of menu items (Like tooltip of button 'sa

Post by Villeroy »

MiguelTeixeira wrote:can be reproduced in Python?
This is the Basic routine from the Tools library which can be translated to Python:

Code: Select all

Function GetRegistryKeyContent(sKeyName as string, Optional bforUpdate as Boolean)
Dim oConfigProvider as Object
Dim aNodePath(0) as new com.sun.star.beans.PropertyValue
	oConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider")
	aNodePath(0).Name = "nodepath"
	aNodePath(0).Value = sKeyName
	If IsMissing(bForUpdate) Then
		GetRegistryKeyContent() = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath())
	Else
		If bForUpdate Then
			GetRegistryKeyContent() = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath())
		Else
			GetRegistryKeyContent() = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath())
		End If
	End If
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JeJe
Volunteer
Posts: 1964
Joined: Wed Mar 09, 2016 2:40 pm

Re: Get properties of menu items (Like tooltip of button 'sa

Post by JeJe »

What menu are you talking about?

You can create your own popupmenu and set the help text for the menu item.

https://www.openoffice.org/api/docs/com ... pMenu.html
https://www.openoffice.org/api/docs/com ... XMenu.html

You can examine the visible windows using Accessibility if its a Toolbar item you're interested in

https://www.openoffice.org/api/docs/com ... le-ix.html

You can intercept context menus. Don't know about the main menubar.
Openoffice 4.1.6
Windows 8
MiguelTeixeira
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

Re: Get properties of menu items (Like tooltip of button 'sa

Post by MiguelTeixeira »

JeJe wrote:What menu are you talking about?
I apologize,
I'm talking about the toolbar (the one with the save, open, print, paste buttons ...)
MX Linux, LibreOffice 6
JeJe
Volunteer
Posts: 1964
Joined: Wed Mar 09, 2016 2:40 pm

Re: Get properties of menu items (Like tooltip of button 'sa

Post by JeJe »

That might be easier... what are you trying to do?

Edit: Is this a re-run of this thread?

viewtopic.php?t=98949
Last edited by JeJe on Sat Feb 08, 2020 8:51 pm, edited 1 time in total.
Openoffice 4.1.6
Windows 8
MiguelTeixeira
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

Re: Get properties of menu items (Like tooltip of button 'sa

Post by MiguelTeixeira »

When the user places the mouse over a button, a popup with help text is displayed. This action is implemented here:

https://github.com/LibreOffice/core/blo ... p.cxx#L480

I would like to access the 'rHelpText' parameter through the UNO API.
I want to identify when the user places the mouse over some tool (save ... open ... print ...)
MX Linux, LibreOffice 6
JeJe
Volunteer
Posts: 1964
Joined: Wed Mar 09, 2016 2:40 pm

Re: Get properties of menu items (Like tooltip of button 'sa

Post by JeJe »

I edited my post to say is this a re-run of this thread just as you posted?

viewtopic.php?t=98949

Anyway... have a look at this thread... you can put a dialog in a toolbar with buttons and probably have a mouseover popup.

viewtopic.php?f=21&t=4352
Openoffice 4.1.6
Windows 8
MiguelTeixeira
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

Re: Get properties of menu items (Like tooltip of button 'sa

Post by MiguelTeixeira »

JeJe wrote:Edit: Is this a re-run of this thread?
Yes. I didn't get any more answers on that topic. I believe I was not being clear enough about what I was looking for.
MX Linux, LibreOffice 6
JeJe
Volunteer
Posts: 1964
Joined: Wed Mar 09, 2016 2:40 pm

Re: Get properties of menu items (Like tooltip of button 'sa

Post by JeJe »

Its better for everyone if you 'bump' the thread up... do another post saying you're still looking for the solution. They usually seems to get unsolved if there isn't a solution or no-one here knows the answer.

Controls in a dialog have a mouseinside event so setting a timer when that happens to show your own popup window might be possible... and having a dialog that mimics a toolbar... floating or like that link above put inside a toolbar. All I can think of, don't know the proper answer here.
Openoffice 4.1.6
Windows 8
User avatar
Villeroy
Volunteer
Posts: 30672
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Get properties of menu items (Like tooltip of button 'sa

Post by Villeroy »

I confirm that the Basic code provided by JeJe

Code: Select all

GlobalScope.BasicLibraries.LoadLibrary("Tools")
c= GetRegistryKeyContent("org.openoffice.Office.UI.GenericCommands")
msgbox c.getbyname("UserInterface").getbyname("Commands").getbyname(".uno:Save").Label
reports the tool tip of the save command. Simply use Basic or translate that little snippet to Python.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JeJe
Volunteer
Posts: 1964
Joined: Wed Mar 09, 2016 2:40 pm

Re: Get properties of menu items (Like tooltip of button 'sa

Post by JeJe »

Villeroy - I think in LibreOffice that may be the case because the tool tip copies the label with the shortcut added (Ctrl + S).

Its not the case in my OO the tool tip text for Save is "Saves the current document" both in the menu and toolbar button. (In my LO there is no tool tip for the menu Save item)

As the OP is using LibreOffice it will work though - for that button anyway.
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
Posts: 1964
Joined: Wed Mar 09, 2016 2:40 pm

Re: Get properties of menu items (Like tooltip of button 'sa

Post by JeJe »

The Expert Configuration in LO is really useful here... it shows all the values for the save command are null except for label.

The correct code in LO is something like:

Code: Select all

GlobalScope.BasicLibraries.LoadLibrary("Tools")
c= GetRegistryKeyContent("org.openoffice.Office.UI.GenericCommands")
cc=c.getbyname("UserInterface").getbyname("Commands").getbyname(".uno:Save")
lbl = cc.ToolTipLabel 
if lbl=nullstring then lbl= cc.Label
msgbox lbl



Edit: Or

Code: Select all

GlobalScope.BasicLibraries.LoadLibrary("Tools")
cc= GetRegistryKeyContent("/org.openoffice.Office.UI.GenericCommands/UserInterface/Commands/org.openoffice.Office.UI.Commands:LabelType['.uno:Save']")
lbl = cc.ToolTipLabel
if lbl=nullstring then lbl= cc.Label
msgbox lbl

Attachments
save.JPG
Openoffice 4.1.6
Windows 8
Post Reply