How do I change the tooltip text for a toolbar button I created?

I created a toolbar button to directly access scanner functions instead of wading through “Insert… Media… Scan… Select Source” when I need to scan something into a document. I assigned it an icon, and gave the button the name “Scan Document,” but the tooltip when the pointer is over the icon comes up as “Select Source,” which is not very intuitive. If I remove the icon, the button displays “Scan Document,” but that occupies far more toolbar real estate than the icon. Is there a way to change the button’s tooltip text to display as “Scan Document”?

Running Libreoffice-24.8.2.1 on 64-bit linux.

See tdf#138337 (“Toolbar command Rename does not affect tooltip”).

There may be a way to change the tooltip text: (1) using a macro or (2) by adding an .xcd file
Both options tested on Windows 11.

(1) Using a macro

Run the following BASIC macro:

sub AddTooltip

GlobalScope.BasicLibraries.LoadLibrary("Tools")
Dim RegKey As Object
RegKey = GetRegistryKeyContent("org.openoffice.Office.UI.GenericCommands/UserInterface/Commands", True)
CommandName = ".uno:TwainSelect"
RegKey.getByName(CommandName).setPropertyValue("TooltipLabel","Scan Document")
RegKey.commitChanges()

end sub

LO will add the appropriate entry in the registrymodifications.xcu file:

<item oor:path="/org.openoffice.Office.UI.GenericCommands/UserInterface/Commands/org.openoffice.Office.UI.Commands:LabelType['.uno:TwainSelect']/TooltipLabel"><value xml:lang="en-US">Scan Document</value></item>

Close and reopen LibreOffice. The result:

rec24821_Win11



(2) adding an .xcd file [1]

The attached file:
TwainSelectTooltip.xcd.odt (661 Bytes)

Change its extension to xcd

Place the TwainSelectTooltip.xcd file in the (...)\share\registry folder

Launch LibreOffice and check the tooltip.


File content:

<?xml version="1.0"?>
 <oor:data xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:oor="http://openoffice.org/2001/registry">
   <dependency file="main" />
<oor:component-data xmlns:install="http://openoffice.org/2004/installation" oor:name="GenericCommands" oor:package="org.openoffice.Office.UI">
		<node oor:name="UserInterface">
			<node oor:name="Commands">
				<node oor:name=".uno:TwainSelect" oor:op="fuse">
					<prop oor:name="TooltipLabel" oor:type="xs:string">
						<value xml:lang="en-US">Scan Document</value>
					</prop>
				</node>
			</node>
		</node>
	</oor:component-data>
</oor:data>



[1] Deployment and Migration - Some tricks for post deployment configuration

4 Likes