Forum Discussion

ysapiyev's avatar
ysapiyev
Responsive Resident
8 years ago
Solved

Multiple selection in custom visual

Hi everyone.

 

I wanted to know, how to do multple selection using pressed CTRL button and mouse click, instead of mouse click. I set

this.selectionManager.select(d.identity, true), and it selects multiple data, but just by mouse click. How to alter it for identification of CTRL button pressed?
  • Hello ysapiyev,

     

    You should use something like this (event documentation):

     

    // event is a mouse event
    
    const isCtrlKeyPressed = event.ctrlKey;
    
    this.selectionManager.select(d.identity, isCtrlKeyPressed);
    
    

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]

     

6 Replies

  • v-viig's avatar
    v-viig
    Community Champion

    Hello ysapiyev,

     

    You should use something like this (event documentation):

     

    // event is a mouse event
    
    const isCtrlKeyPressed = event.ctrlKey;
    
    this.selectionManager.select(d.identity, isCtrlKeyPressed);
    
    

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]

     

    • ysapiyev's avatar
      ysapiyev
      Responsive Resident

      Hello v-viig,

       

      So ,as I understood, it should look like this, right?

      var event =  <Event>d3.event;
      const isCtrlKeyPressed =event.ctrlKey;
      
      this.selectionManager.select(d.identity, isCtrlKeyPressed);

      However, it shows me that there is no property ctrlKey in event. I googled, and it gives me similar solution as yours. What can be wrong?

       

      Regards,

      Yerkhan

    • ysapiyev's avatar
      ysapiyev
      Responsive Resident

      Hello  v-viig,

       

      Could you have a look at my problem?

       

      Regards

      Yerkhan

      • v-viig's avatar
        v-viig
        Community Champion

        That code snippet looks good.

        Can you share the whole source code for debugging?

         

        Ignat Vilesov,

        Software Engineer

         

        Microsoft Power BI Custom Visuals

        [email protected]