Page 1 of 1

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

Posted: Sat Feb 08, 2020 3:35 am
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,

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

Posted: Sat Feb 08, 2020 3:57 am
by robleyd

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

Posted: Sat Feb 08, 2020 9:35 am
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. )

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

Posted: Sat Feb 08, 2020 12:53 pm
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.

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

Posted: Sat Feb 08, 2020 7:40 pm
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,

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

Posted: Sat Feb 08, 2020 8:05 pm
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

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

Posted: Sat Feb 08, 2020 8:38 pm
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.

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

Posted: Sat Feb 08, 2020 8:43 pm
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 ...)

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

Posted: Sat Feb 08, 2020 8:48 pm
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

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

Posted: Sat Feb 08, 2020 8:50 pm
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 ...)

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

Posted: Sat Feb 08, 2020 9:01 pm
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

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

Posted: Sat Feb 08, 2020 9:01 pm
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.

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

Posted: Sat Feb 08, 2020 10:02 pm
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.

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

Posted: Sat Feb 08, 2020 10:55 pm
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.

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

Posted: Sun Feb 09, 2020 1:16 am
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.

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

Posted: Sun Feb 09, 2020 2:18 am
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