A specialized subclass of PopulateContextMenuEventArgs that carries the item for which the context menu should be populated.
Type Parameters
- TModelItem
- The type of the model
.
Type Details
- yFiles module
- view
Constructors
PopulateItemContextMenuEventArgs
(context: IInputModeContext, queryLocation: Point, item: TModelItem)Initializes a new instance of the PopulateItemContextMenuEventArgs<TModelItem> class.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to populate the menu for.
- queryLocation - Point
- The query location.
- item - TModelItem
- The item for which the context menu should be populated, may be
null
.
Properties
Gets the context for the current event.
Gets or sets the context menu content to use.
Remarks
The content can be either a string, any HTML element or a Promise providing the same.
Setting this property will set the handled and showMenu property to true
.
If this property is not specified, no context menu will appear.
Property Value
null
if no context menu should be displayed.Defined in
Gets or sets a value indicating whether this PopulateContextMenuEventArgs has been handled.
Remarks
If this event is marked as handled, the input mode will use the property contextMenu to decide whether to show the context menu.
This property is automatically set to true
if a value is assigned to the property contextMenu.
Note that this property needs to be set before the function synchronously returns. This means that setting the value in an async
function after the first await
or in an asynchronous callback, it cannot not be seen by the emitter of the event and the sender will consider the event as not being handled.
// wrong:
mode.addEventListener('populate-menu', async (evt) => {
await something()
evt.handled = true // will be set *after* all other event listeners have been invoked, only
})
// correct:
mode.addEventListener('populate-menu', async (evt) => {
evt.handled = true // will be set immediately and 'mode' will see the change
await something()
})
Property Value
true
if handled; false
otherwise.Defined in
Gets the queried location in world coordinates.
Gets or sets a value indicating whether to actually display the context menu.
Remarks
This may be useful, when the application or a framework should render the actual context menu but the event handling is done by the ContextMenuInputMode.
This will set the handled property to true
.
The default value of this property is true
.
Property Value
true
if the menu should be shown; false
otherwise.