for instance, I added Autodesk built-in extension in ForgeViewer.js as below:
viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('forgeViewer'), { extensions: ['Autodesk.VisualClusters'] });
after run, default tool tips will display "Form Clusters By Category", how to override it say "Form Clusters"?
Unfortunately, the tooltip is hardcoded in the extension code with a literal string, so there in no way to pass a new string as parameter. However, you can override the tooltip with the following code.
const ext = myViewer.getExtension('Autodesk.VisualClusters');
ext.clusterButton.setToolTip('my tooltip');
If you want to do it during the Viewer initialisation you can use the 'EXTENSION_LOADED_EVENT' event and wait for the button to be created:
myViewer.addEventListener(Autodesk.Viewing.EXTENSION_LOADED_EVENT,
(event) => {
const ext = myViewer.getExtension('Autodesk.VisualClusters');
if ( ext )
setTimeout(() => { ext.clusterButton.setToolTip('my tooltip'); }, 500);
});
or using the event object
myViewer.addEventListener(Autodesk.Viewing.EXTENSION_LOADED_EVENT,
(event) => {
if ( event.extensionId === 'Autodesk.VisualClusters' )
setTimeout(() => {
event.target.getExtension(event.extensionId).clusterButton.setToolTip('my tooltip');
}, 500);
});