Class JPopupMenuHelper
java.lang.Object
com.inductiveautomation.ignition.client.util.gui.popup.JPopupMenuHelper
- All Implemented Interfaces:
MouseListener
,EventListener
,PopupMenuListener
This class contains the correct logic for a component that wants to pop up a popup menu. You'd think this was
unnecessary, but it's tricky to do correctly because if you pop up the popup on mouse press, it'll be wrong in the
case when the press should "toggle" the popup's visibility. This is because The press will first hide the popup
automatically, and then the press would show the popup again.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Component
protected long
protected PopupLocation
protected boolean
protected JPopupMenu
protected Supplier<JPopupMenu>
protected long
protected PopupTrigger
-
Constructor Summary
ConstructorsConstructorDescriptionJPopupMenuHelper
(Component component, Supplier<JPopupMenu> popupMaker) Alternate constructor allows for lazy popup instantiationJPopupMenuHelper
(Component component, JPopupMenu popup) -
Method Summary
Modifier and TypeMethodDescriptionprotected Point
adjustPopupLocationToFitScreen
(int xPosition, int yPosition) Moves the popup location so that the menu does not overlap the task bar.protected Point
adjustPopupLocationToFitWindow
(int xPosition, int yPosition) void
bind()
static void
bind
(Component component, JPopupMenu popup) Creates a PopupHelper with trigger=OnPress, location=UnderneathComponent, and threshold=20ms and binds it.void
getPopup()
long
boolean
void
void
void
void
void
void
void
void
void
setComponent
(Component component) void
setLocation
(PopupLocation location) void
setMemoizePopup
(boolean memoizePopup) Controls whether the menu supplier is only called once (the default) or every time the popup is shown.void
setPopup
(JPopupMenu popup) void
setThreshold
(long threshold) void
setTrigger
(PopupTrigger trigger) void
unbind()
-
Field Details
-
component
-
popup
-
popupMaker
-
trigger
-
location
-
memoizePopup
protected boolean memoizePopup -
lastHidden
protected long lastHidden -
threshold
protected long threshold
-
-
Constructor Details
-
JPopupMenuHelper
-
JPopupMenuHelper
Alternate constructor allows for lazy popup instantiation
-
-
Method Details
-
bind
public void bind() -
unbind
public void unbind() -
bind
Creates a PopupHelper with trigger=OnPress, location=UnderneathComponent, and threshold=20ms and binds it. -
setTrigger
-
getTrigger
-
setLocation
-
getLocation
-
getThreshold
public long getThreshold() -
setThreshold
public void setThreshold(long threshold) -
setComponent
-
getComponent
-
setPopup
-
getPopup
-
setMemoizePopup
public void setMemoizePopup(boolean memoizePopup) Controls whether the menu supplier is only called once (the default) or every time the popup is shown. This setting is only used if the popup menu helper was created with a menu supplier. -
isMemoizePopup
public boolean isMemoizePopup() -
popupMenuWillBecomeVisible
- Specified by:
popupMenuWillBecomeVisible
in interfacePopupMenuListener
-
popupMenuWillBecomeInvisible
- Specified by:
popupMenuWillBecomeInvisible
in interfacePopupMenuListener
-
popupMenuCanceled
- Specified by:
popupMenuCanceled
in interfacePopupMenuListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
doShowPopup
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
adjustPopupLocationToFitScreen
Moves the popup location so that the menu does not overlap the task bar. This is taken from JPopupMenu.java. The JPopupMenu version has a condition that can allow the screen insets to not be considered in the adjustment. This was taken in full in order to perform the same function while forcing the insets to be part of the adjustment. -
adjustPopupLocationToFitWindow
-