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

Creating a macro - Writing a Script - Using the API

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

Postby MiguelTeixeira » Sat Feb 08, 2020 3:35 am

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
MiguelTeixeira
 
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

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

Postby robleyd » Sat Feb 08, 2020 3:57 am

Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 14.2 - 64 bit
LibreOffice 6.4.6.2 (SlackBuild for 6.4.6 by Eric Hameleers) - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 3743
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

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

Postby Zizi64 » Sat Feb 08, 2020 9:35 am

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&hilit=Fill_Cell_Backgrounds#p168101

(In my opinion only the Toolbar icons have tooltips, but the menu items have not. )
Tibor Kovacs, Hungary; LO6.1.6, 6.2.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.4.5;AOO4.1.7
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.
User avatar
Zizi64
Volunteer
 
Posts: 9718
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

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

Postby JeJe » Sat Feb 08, 2020 12:53 pm

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   Expand viewCollapse view
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
JeJe
Volunteer
 
Posts: 1397
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby MiguelTeixeira » Sat Feb 08, 2020 7:40 pm

Hi,

Thank you very much for your answers!
@JeJe, you know how the stretch:
Code: Select all   Expand viewCollapse view
"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
MiguelTeixeira
 
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

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

Postby Villeroy » Sat Feb 08, 2020 8:05 pm

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   Expand viewCollapse view
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, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 29259
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Postby JeJe » Sat Feb 08, 2020 8:38 pm

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
JeJe
Volunteer
 
Posts: 1397
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby MiguelTeixeira » Sat Feb 08, 2020 8:43 pm

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
MiguelTeixeira
 
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

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

Postby JeJe » Sat Feb 08, 2020 8:48 pm

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
JeJe
Volunteer
 
Posts: 1397
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby MiguelTeixeira » Sat Feb 08, 2020 8:50 pm

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
MiguelTeixeira
 
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

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

Postby JeJe » Sat Feb 08, 2020 9:01 pm

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
JeJe
Volunteer
 
Posts: 1397
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby MiguelTeixeira » Sat Feb 08, 2020 9:01 pm

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
MiguelTeixeira
 
Posts: 9
Joined: Sun Aug 11, 2019 2:17 am

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

Postby JeJe » Sat Feb 08, 2020 10:02 pm

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
JeJe
Volunteer
 
Posts: 1397
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby Villeroy » Sat Feb 08, 2020 10:55 pm

I confirm that the Basic code provided by JeJe
Code: Select all   Expand viewCollapse view
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, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 29259
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Postby JeJe » Sun Feb 09, 2020 1:16 am

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: 1397
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby JeJe » Sun Feb 09, 2020 2:18 am

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   Expand viewCollapse view
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   Expand viewCollapse view
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
JeJe
Volunteer
 
Posts: 1397
Joined: Wed Mar 09, 2016 2:40 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 8 guests