- handle Ctrl-KEY

This commit is contained in:
Richard Alam 2012-08-10 15:59:12 +00:00
parent eef20d38c1
commit 41e2f1cc0d
7 changed files with 56 additions and 10 deletions

View File

@ -81,7 +81,21 @@ package org.bigbluebutton.modules.whiteboard
public function changeFontSize(size:Number):void {
wbTool._fontSize = size;
}
public function onKeyDown(event:KeyboardEvent):void {
LogUtil.debug("CTRL-Key DOWN");
for (var ob:int = 0; ob < drawListeners.length; ob++) {
(drawListeners[ob] as IDrawListener).ctrlKeyDown(event.ctrlKey);
}
}
public function onKeyUp(event:KeyboardEvent):void {
LogUtil.debug("CTRL-Key UP");
for (var ob:int = 0; ob < drawListeners.length; ob++) {
(drawListeners[ob] as IDrawListener).ctrlKeyDown(event.ctrlKey);
}
}
public function doMouseUp(mouseX:Number, mouseY:Number):void {
// LogUtil.debug("CanvasModel doMouseUp ***");
for (var ob:int = 0; ob < drawListeners.length; ob++) {

View File

@ -19,7 +19,7 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.display.Shape;
import flash.display.Sprite;
/**
@ -186,7 +186,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
protected function readyToSend():Boolean {
return false;
}
public function makeGraphic(pW:Number, pH:Number):void {
return;
}
@ -194,9 +194,5 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
public function getProperties():Array {
return null;
}
// public function toString():String {
// return "[DrawObject] You should override this."
// }
}
}

View File

@ -57,7 +57,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
this.shape.push(x2);
this.shape.push(y2);
}
override public function makeGraphic(parentWidth:Number, parentHeight:Number):void {
if(!fill)
this.graphics.lineStyle(getThickness(), getColor(), getTransparencyLevel());

View File

@ -7,5 +7,6 @@ package org.bigbluebutton.modules.whiteboard.views
function onMouseDown(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void;
function onMouseMove(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void;
function onMouseUp(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void;
function ctrlKeyDown(down:Boolean):void;
}
}

View File

@ -17,6 +17,7 @@ package org.bigbluebutton.modules.whiteboard.views
private var _wbCanvas:WhiteboardCanvas;
private var _sendFrequency:int;
private var _shapeFactory:ShapeFactory;
private var _ctrlKeyDown:Boolean = false;
public function PencilDrawListener(wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory)
{
@ -36,6 +37,11 @@ package org.bigbluebutton.modules.whiteboard.views
}
}
public function ctrlKeyDown(down:Boolean):void {
_ctrlKeyDown = down;
}
public function onMouseMove(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void
{
if (tool.graphicType == WhiteboardConstants.TYPE_SHAPE) {
@ -117,6 +123,14 @@ package org.bigbluebutton.modules.whiteboard.views
annotation["fillColor"] = dobj.getFillColor();
annotation["transparency"] = dobj.getTransparency();
if (tool.toolType == DrawObject.RECTANGLE && _ctrlKeyDown) {
annotation["square"] = true;
}
if (tool.toolType == DrawObject.ELLIPSE && _ctrlKeyDown) {
annotation["circle"] = true;
}
var msg:Annotation = new Annotation(dobj.getGraphicID(), dobj.getType(), annotation);
_wbCanvas.sendGraphicToServer(msg, WhiteboardDrawEvent.SEND_SHAPE);
}

View File

@ -26,6 +26,10 @@ package org.bigbluebutton.modules.whiteboard.views
_shapeFactory = shapeFactory;
}
public function ctrlKeyDown(down:Boolean):void {
// Ignore
}
public function onMouseDown(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void
{
if(tool.graphicType == WhiteboardConstants.TYPE_TEXT) {

View File

@ -81,12 +81,24 @@
addEventListener(MouseEvent.MOUSE_DOWN, doMouseDown);
addEventListener(MouseEvent.MOUSE_UP, doMouseUp);
addEventListener(MouseEvent.MOUSE_MOVE, doMouseMove);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
}
public function unregisterForMouseEvents():void {
removeEventListener(MouseEvent.MOUSE_DOWN, doMouseDown);
removeEventListener(MouseEvent.MOUSE_UP, doMouseUp);
removeEventListener(MouseEvent.MOUSE_MOVE, doMouseMove);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);
}
private function onKeyDown(event:KeyboardEvent):void {
model.onKeyDown(event);
}
private function onKeyUp(event:KeyboardEvent):void {
model.onKeyUp(event);
}
private function doMouseUp(event:Event):void {
@ -175,8 +187,13 @@
}
private function setWhiteboardVisibility():void {
if (this.whiteboardEnabled && this.showWhiteboard) this.visible = true;
else this.visible = false;
if (this.whiteboardEnabled && this.showWhiteboard) {
this.visible = true;
registerForMouseEvents();
} else {
this.visible = false;
unregisterForMouseEvents();
}
}
/* added this functionality in WhiteboardToolbar.mxml instead to allow a variety of cursors */