mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GP-3254 - Added a Front End tool option to disable application-wide
tooltips
This commit is contained in:
parent
528c0a8b94
commit
fabdc3739c
6 changed files with 85 additions and 15 deletions
|
@ -40,6 +40,7 @@ import docking.widgets.tree.support.GTreeRenderer;
|
|||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import ghidra.docking.util.LookAndFeelUtils;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import ghidra.util.Swing;
|
||||
import resources.ResourceManager;
|
||||
|
||||
/**
|
||||
|
@ -353,14 +354,38 @@ public class DockingUtils {
|
|||
c.setBackground(Palette.NO_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the application-wide Java tooltip enablement.
|
||||
* @param enabled true if enabled; false prevents all Java tooltips
|
||||
*/
|
||||
public static void setTipWindowEnabled(boolean enabled) {
|
||||
Swing.runLater(() -> ToolTipManager.sharedInstance().setEnabled(enabled));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if application-wide Java tooltips are enabled.
|
||||
* @return true if application-wide Java tooltips are enabled.
|
||||
*/
|
||||
public static boolean isTipWindowEnabled() {
|
||||
return Swing.runNow(() -> ToolTipManager.sharedInstance().isEnabled());
|
||||
}
|
||||
|
||||
/** Hides any open tooltip window */
|
||||
public static void hideTipWindow() {
|
||||
// This is a hack, since Java's manager doesn't have this method
|
||||
javax.swing.ToolTipManager.sharedInstance().setEnabled(false);
|
||||
javax.swing.ToolTipManager.sharedInstance().setEnabled(true);
|
||||
|
||||
// TODO: Ultimately, the ESCAPE key binding in the Java TTM should hide any visible tooltips. We
|
||||
// need to look into why this isn't working.
|
||||
Swing.runLater(() -> {
|
||||
ToolTipManager ttm = ToolTipManager.sharedInstance();
|
||||
if (!ttm.isEnabled()) {
|
||||
return; // nothing to do
|
||||
}
|
||||
|
||||
//
|
||||
// This is a hack, since Java's manager doesn't have this method. Calling
|
||||
// setEnabled(false) will close any open tooltips.
|
||||
//
|
||||
ttm.setEnabled(false);
|
||||
ttm.setEnabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import javax.swing.*;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.shapes.*;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import generic.util.WindowUtilities;
|
||||
|
@ -226,12 +227,32 @@ public class PopupWindow {
|
|||
closeTimer.setRepeats(false);
|
||||
}
|
||||
|
||||
public void showOffsetPopup(MouseEvent e, Rectangle keepVisibleSize) {
|
||||
doShowPopup(e, keepVisibleSize, DEFAULT_WINDOW_PLACER);
|
||||
public void showOffsetPopup(MouseEvent e, Rectangle keepVisibleSize, boolean forceShow) {
|
||||
if (forceShow || DockingUtils.isTipWindowEnabled()) {
|
||||
doShowPopup(e, keepVisibleSize, DEFAULT_WINDOW_PLACER);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows this popup window unless popups are disabled as reported by
|
||||
* {@link DockingUtils#isTipWindowEnabled()}.
|
||||
* @param e the event
|
||||
*/
|
||||
public void showPopup(MouseEvent e) {
|
||||
doShowPopup(e, null, DEFAULT_WINDOW_PLACER);
|
||||
showPopup(e, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows this popup window unless popups are disabled as reported by
|
||||
* {@link DockingUtils#isTipWindowEnabled()}. If {@code forceShow} is true, then the popup
|
||||
* will be shown regardless of the state returned by {@link DockingUtils#isTipWindowEnabled()}.
|
||||
* @param e the event
|
||||
* @param forceShow true to show the popup even popups are disabled application-wide
|
||||
*/
|
||||
public void showPopup(MouseEvent e, boolean forceShow) {
|
||||
if (forceShow || DockingUtils.isTipWindowEnabled()) {
|
||||
doShowPopup(e, null, DEFAULT_WINDOW_PLACER);
|
||||
}
|
||||
}
|
||||
|
||||
private void doShowPopup(MouseEvent e, Rectangle keepVisibleSize, PopupWindowPlacer placer) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue