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 SummaryFieldsModifier and TypeFieldDescriptionprotected Componentprotected longprotected PopupLocationprotected booleanprotected JPopupMenuprotected Supplier<JPopupMenu>protected longprotected PopupTrigger
- 
Constructor SummaryConstructorsConstructorDescriptionJPopupMenuHelper(Component component, Supplier<JPopupMenu> popupMaker) Alternate constructor allows for lazy popup instantiationJPopupMenuHelper(Component component, JPopupMenu popup) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected PointadjustPopupLocationToFitScreen(int xPosition, int yPosition) Moves the popup location so that the menu does not overlap the task bar.protected PointadjustPopupLocationToFitWindow(int xPosition, int yPosition) voidbind()static voidbind(Component component, JPopupMenu popup) Creates a PopupHelper with trigger=OnPress, location=UnderneathComponent, and threshold=20ms and binds it.voidgetPopup()longbooleanvoidvoidvoidvoidvoidvoidvoidvoidvoidsetComponent(Component component) voidsetLocation(PopupLocation location) voidsetMemoizePopup(boolean memoizePopup) Controls whether the menu supplier is only called once (the default) or every time the popup is shown.voidsetPopup(JPopupMenu popup) voidsetThreshold(long threshold) voidsetTrigger(PopupTrigger trigger) voidunbind()
- 
Field Details- 
component
- 
popup
- 
popupMaker
- 
trigger
- 
location
- 
memoizePopupprotected boolean memoizePopup
- 
lastHiddenprotected long lastHidden
- 
thresholdprotected long threshold
 
- 
- 
Constructor Details- 
JPopupMenuHelper
- 
JPopupMenuHelperAlternate constructor allows for lazy popup instantiation
 
- 
- 
Method Details- 
bindpublic void bind()
- 
unbindpublic void unbind()
- 
bindCreates a PopupHelper with trigger=OnPress, location=UnderneathComponent, and threshold=20ms and binds it.
- 
setTrigger
- 
getTrigger
- 
setLocation
- 
getLocation
- 
getThresholdpublic long getThreshold()
- 
setThresholdpublic void setThreshold(long threshold) 
- 
setComponent
- 
getComponent
- 
setPopup
- 
getPopup
- 
setMemoizePopuppublic 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.
- 
isMemoizePopuppublic boolean isMemoizePopup()
- 
popupMenuWillBecomeVisible- Specified by:
- popupMenuWillBecomeVisiblein interface- PopupMenuListener
 
- 
popupMenuWillBecomeInvisible- Specified by:
- popupMenuWillBecomeInvisiblein interface- PopupMenuListener
 
- 
popupMenuCanceled- Specified by:
- popupMenuCanceledin interface- PopupMenuListener
 
- 
mouseClicked- Specified by:
- mouseClickedin interface- MouseListener
 
- 
doShowPopup
- 
mousePressed- Specified by:
- mousePressedin interface- MouseListener
 
- 
mouseReleased- Specified by:
- mouseReleasedin interface- MouseListener
 
- 
mouseEntered- Specified by:
- mouseEnteredin interface- MouseListener
 
- 
mouseExited- Specified by:
- mouseExitedin interface- MouseListener
 
- 
adjustPopupLocationToFitScreenMoves 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
 
-