<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Context menu for visualisation that doesn't need it.... in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Context-menu-for-visualisation-that-doesn-t-need-it/m-p/4125499#M10433</link>
    <description>&lt;P&gt;I have a visualisation which has no great need for a context menu other than to be consistent with other Power BI custom visuals. The visual does not use the d3 library, and I can't find a sample to copy off which also doesn't. I'm wondering how I might be able to incorporate it easily?&lt;/P&gt;&lt;P&gt;The current code I'm using is as follows, and it gets all a bit messy in the 'private handleContextMenu' method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import ISelectionManager = powerbi.extensibility.ISelectionManager;

export class Visual implements IVisual {
  private selectionManager: ISelectionManager;
}
constructor(options: VisualConstructorOptions) {
        this.handleContextMenu();
}
private handleContextMenu() {
        const mouseEvent: MouseEvent = addEventListener as MouseEvent;
        const eventTarget: EventTarget = mouseEvent.target;
        this.selectionManager.showContextMenu(Selection, { x: MouseEvent.clientX, y: MouseEvent.clientY });
          mouseEvent.preventDefault();
  }&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Is anyone able to provide a method which would be able to enable the default context menu of 'Show as table/copy/chat in teams'?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 29 Aug 2024 18:19:30 GMT</pubDate>
    <dc:creator>popeadam</dc:creator>
    <dc:date>2024-08-29T18:19:30Z</dc:date>
    <item>
      <title>Context menu for visualisation that doesn't need it....</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Context-menu-for-visualisation-that-doesn-t-need-it/m-p/4125499#M10433</link>
      <description>&lt;P&gt;I have a visualisation which has no great need for a context menu other than to be consistent with other Power BI custom visuals. The visual does not use the d3 library, and I can't find a sample to copy off which also doesn't. I'm wondering how I might be able to incorporate it easily?&lt;/P&gt;&lt;P&gt;The current code I'm using is as follows, and it gets all a bit messy in the 'private handleContextMenu' method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import ISelectionManager = powerbi.extensibility.ISelectionManager;

export class Visual implements IVisual {
  private selectionManager: ISelectionManager;
}
constructor(options: VisualConstructorOptions) {
        this.handleContextMenu();
}
private handleContextMenu() {
        const mouseEvent: MouseEvent = addEventListener as MouseEvent;
        const eventTarget: EventTarget = mouseEvent.target;
        this.selectionManager.showContextMenu(Selection, { x: MouseEvent.clientX, y: MouseEvent.clientY });
          mouseEvent.preventDefault();
  }&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Is anyone able to provide a method which would be able to enable the default context menu of 'Show as table/copy/chat in teams'?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 Aug 2024 18:19:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Context-menu-for-visualisation-that-doesn-t-need-it/m-p/4125499#M10433</guid>
      <dc:creator>popeadam</dc:creator>
      <dc:date>2024-08-29T18:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Context menu for visualisation that doesn't need it....</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Context-menu-for-visualisation-that-doesn-t-need-it/m-p/4131319#M10473</link>
      <description>&lt;P&gt;Managed to resolve this using the d3 library:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import {select} from "d3";

export class Visual implements IVisual {
  private selectionManager: ISelectionManager;

  constructor(options: VisualConstructorOptions) {
        this.selectionManager = options.host.createSelectionManager();
        this.handleContextMenu();
    }
    private handleContextMenu() {
        select(this.target).on("contextmenu", (event: MouseEvent) =&amp;gt; {
            this.selectionManager.showContextMenu({}, {
                x: event.clientX,
                y: event.clientY,
            });
            event.preventDefault();
        });
    }


&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 13:06:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Context-menu-for-visualisation-that-doesn-t-need-it/m-p/4131319#M10473</guid>
      <dc:creator>popeadam</dc:creator>
      <dc:date>2024-09-03T13:06:32Z</dc:date>
    </item>
  </channel>
</rss>

