SelectionContextMenu

A context menu for word-selection operations. Shown when the user right-clicks on a word that belongs to an active word selection. Provides "Add link" and "Search text" actions.

Constructor

new SelectionContextMenu(x, y, callbacks)

Parameters:
NameTypeDescription
xnumberPreferred left position in viewport pixels.
ynumberPreferred top position in viewport pixels.
callbacksobjectCallback functions for menu actions.
Properties
NameTypeAttributesDescription
onAddLinkfunction<optional>
Called when "Add link" is clicked.
onSearchTextfunction<optional>
Called when "Search text" is clicked.
onGenerateLiveQuotefunction<optional>
Called when "Generate Live Quote" is clicked. Pass null to hide the item.
onMutefunction<optional>
Called when "Mute" is clicked. Pass null to hide the item.
onApplyEffectfunction<optional>
Called when "Apply effect" is clicked. Pass null to hide the item.
applyEffectDisabledReasonstring | null<optional>
Tooltip/reason shown when apply effect is disabled. Pass null if not disabled.
onAddNotefunction<optional>
Called when "Add note" is clicked. Pass null to hide the item.
onDismissfunction<optional>
Called when the menu is dismissed.
infoObject | null<optional>
Info widget config passed to the base ContextMenu.
Example
const menu = new SelectionContextMenu(event.clientX, event.clientY, {
  onAddLink:          () => { handleHyperlink(); },
  onSearchText:       () => { handleSearch(); },
  onGenerateLiveQuote: () => { handleEmbed(); },  // null to hide
  onMute:             () => { handleMute(); },    // null to hide
  onApplyEffect:      () => { handleEffect(); },  // null to hide
  onDismiss:          () => { menu.close(); },
});

// Later:
menu.close();

Classes

SelectionContextMenu