Cannot set tooltip to ComponentWithBrowseButton's button 关注
已回答
223.7571.123-EAP-SNAPSHOT
My class extends ComponentWithBrowseButton and I need to set a tooltip text for the button. I use
getButton().setToolTipText("My text");
But the method getButton is marked as Deprecated with forRemoval=true. So I look for a legal way to set the tooltip. The ComponentWithBrowseButton's constructor contains the code:
myBrowseButton.setToolTipText(getIconTooltip());
// FixedSizeButton isn't focusable but it should be selectable via keyboard.
if (ApplicationManager.getApplication() != null) { // avoid crash at design time
new MyDoClickAction(myBrowseButton).registerShortcut(myComponent);
}
Looks like it allows to customise tooltip through the overriding getIconTooltip, but registerShortcut sets own tooltip text anyway.
请先登录再写评论。
Hi Anton,
It seems that the class wasn’t designed to handle custom button tooltips, and there is no good solution for this.
I suggest using
ExtendableTextComponent
if it matches your use case, or creating an issue on https://youtrack.jetbrains.com/issues/IDEA with a proposal to add the tooltip customization possibility inComponentWithBrowseButton
.