JavaScript Graphics Library (JSGL.org) Draw and move interactive vector graphics easily in Javascript!

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

mouse-event [2016/05/08 16:44]
John English [isAltKey() : Boolean]
mouse-event [2016/05/08 16:45] (current)
John English [isAltKey() : Boolean]
Line 399: Line 399:
  
 version 2.0 version 2.0
-==== isAltKey() : Boolean ==== 
-<html></code></html> 
  
-Tests if the Alt key was pressed when the current mouse event occurred.  
- 
-=== Returns === 
- 
-''Boolean'' 
- 
-=== Example === 
- 
-Change the color of the circle according to whether the Alt key was pressed when the mouse was clicked: 
- 
-<code javascript> 
-myPanel.addClickListener(function(eventArgs) { 
-    if (eventArgs.isAltKey()) { 
-      myCircle.getFill().setColor("red"); 
-    } 
-    else { 
-      myCircle.getFill().setColor("green"); 
-    } 
-  }); 
-</code> 
-The above code can be used to produce something like this: 
-<html> 
-<div id='isaltkeyholder' style='width: 250px; height: 150px; border: 1px solid black'></div> 
-<script type="text/javascript"> 
-var isAltKeyPanel = new jsgl.Panel(document.getElementById('isaltkeyholder')); 
-var isAltKeyCircle = isAltKeyPanel.createCircle(); 
-isAltKeyPanel.addElement(isAltKeyCircle); 
-with(isAltKeyCircle.getStroke()) { 
-  setWeight(3); 
-  setColor('red'); 
-} 
-isAltKeyCircle.getFill().setColor('blue'); 
-isAltKeyCircle.setRadius(20); 
-isAltKeyCircle.setCenterLocationXY(125,75); 
- 
-isAltKeyPanel.addClickListener(function(eventArgs) { 
-    if (eventArgs.isAltKey()) { 
-      isAltKeyCircle.getFill().setColor('red'); 
-    } 
-    else { 
-      isAltKeyCircle.getFill().setColor('green'); 
-    } 
-  }); 
-</script> 
-</html> 
- 
-=== Since === 
- 
-version 2.1 
- 
-{{anchor:getsourceelement}} 
-<html><code></html> 
 ===== See Also ===== ===== See Also =====
  
 [[Mouse Events|Mouse Events]] [[Mouse Events|Mouse Events]]
 
mouse-event.txt · Last modified: 2016/05/08 16:45 by John English
 
Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.3
Driven by DokuWiki Powered by PHP Valid XHTML 1.0 Valid CSS