Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Keydown Event in MVC (Read 1693 times)
Megan1717
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 39
Joined: Jun 20th, 2016
Keydown Event in MVC
May 18th, 2020 at 5:54pm
Print Post  
Hello,

I need to be able to get the keydown event, such as when the user presses the Delete key, in order to do some business logic. In the Silverlight version of MindFusion, we tapped into the Diagram's KeyDown event property and then attached an event handler to the diagram: diagram.KeyDown += diagram_KeyDown.

In the MVC verision, event handlers appear to be added using various properties available to the DiagramView class, such NodeClickedScript and LinkCreatedScript. We do this successfully in the server side code for several evens. However, there does not appear to be a keydown or keypress property to tap into for the DiagramView, Diagram, or Events classes.

I have tried adding the JS onkeydown event listener to the diagram and to the document on the client side, but this never seems to fire.

How can we tap into the keydown event on the client side for MVC?

Thanks.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Keydown Event in MVC
Reply #1 - May 19th, 2020 at 5:00am
Print Post  
Hi,

The diagram uses a hidden div to track focus, in order to avoid browsers' auto-scroll behavior when clicked. Try attaching your handler to it -

Code
Select All
var diagramFocusDiv = diagram.focusDiv;
diagramFocusDiv.addEventListener(
    "keydown", myKeyDownHandler); 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Megan1717
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 39
Joined: Jun 20th, 2016
Re: Keydown Event in MVC
Reply #2 - May 19th, 2020 at 9:18pm
Print Post  
This is perfect. Thanks very much!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint