Interface CanvasContextMenuProvider
public interface CanvasContextMenuProvider
Use
Internally the right-click handling looks like this:
ScreenSpaceCanvas.addContextMenuProvider(CanvasContextMenuProvider)
to add menu items into the context menu generated by Bookmap. Internally the right-click handling looks like this:
- A right-click event occurs
getRightClickEventScore(CanvasMouseEvent)is called for every module- Bookmap finds a module with the highest score
- If this module is different from the previously focused one,
onFocusLost()is called on the previous one - Bookmap calls
onFocusGained()on the newly focused module - Bookmap calls
getMenuItems(CanvasMouseEvent)on every module, and combines obtained menu items into one context menu - Context menu is shown
-
Method Summary
Modifier and TypeMethodDescriptionOn right-click Bookmap asks everyCanvasContextMenuProviderto provide a list of menu items.default intEveryCanvasContextMenuProvideron every right-click is asked to "vote" for this event.default voidCalled if this module wins the voting for a right-click eventdefault voidCalled afteronFocusGained(), when some other module wins the voting for another mouse event
-
Method Details
-
getRightClickEventScore
EveryCanvasContextMenuProvideron every right-click is asked to "vote" for this event. The module which provided the highest score - wins, and itsonFocusGained()is called.Use
MouseModuleScoreas a reference for your values, e.g. if you want your module to capture focus on trade circles/indicator lines, return the score higher thanMouseModuleScore.GRAPH_LAYERS_MODULES_MAX.You can track focus state with
onFocusGained()/onFocusLost(), and insert different menu items based on it.- Parameters:
e- right click mouse event- Returns:
- score in range [
MouseModuleScore.MIN,MouseModuleScore.MAX] if you want to obtain focus for this event,MouseModuleScore.NONEotherwise. - Throws:
IllegalArgumentException- if score is out of range [MouseModuleScore.MIN,MouseModuleScore.MAX] and not equal toMouseModuleScore.NONE- See Also:
-
onFocusGained
default void onFocusGained()Called if this module wins the voting for a right-click event -
onFocusLost
default void onFocusLost()Called afteronFocusGained(), when some other module wins the voting for another mouse event -
getMenuItems
On right-click Bookmap asks everyCanvasContextMenuProviderto provide a list of menu items.- Parameters:
e- a right-click event that you can use to decide what to include in the resulting menu.- Returns:
JMenuItems that should be included into Bookmap-generated context menu
-