mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-26 09:59:10 -07:00
Added events for FP 11.2: RIGHT_CLICK, RIGHT_MOUSE_DOWN, RIGHT_MOUSE_UP. Need use FP 11.2 and -swf-version=15. #8
This commit is contained in:
@@ -326,7 +326,8 @@ public class Camera3D extends Object3D {
|
||||
view.calculateRays(this, (globalMouseHandlingType & Object3D.MOUSE_HANDLING_MOVING) != 0,
|
||||
(globalMouseHandlingType & Object3D.MOUSE_HANDLING_PRESSING) != 0,
|
||||
(globalMouseHandlingType & Object3D.MOUSE_HANDLING_WHEEL) != 0,
|
||||
(globalMouseHandlingType & Object3D.MOUSE_HANDLING_MIDDLE_BUTTON) != 0);
|
||||
(globalMouseHandlingType & Object3D.MOUSE_HANDLING_MIDDLE_BUTTON) != 0,
|
||||
(globalMouseHandlingType & Object3D.MOUSE_HANDLING_RIGHT_BUTTON) != 0);
|
||||
for (i = origins.length; i < view.raysLength; i++) {
|
||||
origins[i] = new Vector3D();
|
||||
directions[i] = new Vector3D();
|
||||
|
||||
@@ -188,6 +188,10 @@ package alternativa.engine3d.core {
|
||||
* @private
|
||||
*/
|
||||
alternativa3d static const MOUSE_HANDLING_MIDDLE_BUTTON:uint = 8;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
alternativa3d static const MOUSE_HANDLING_RIGHT_BUTTON:uint = 16;
|
||||
|
||||
/**
|
||||
* Custom data available to store within <code>Object3D</code> by user.
|
||||
@@ -747,6 +751,9 @@ package alternativa.engine3d.core {
|
||||
if (type == MouseEvent3D.MIDDLE_CLICK || type == MouseEvent3D.MIDDLE_MOUSE_DOWN || type == MouseEvent3D.MIDDLE_MOUSE_UP) {
|
||||
mouseHandlingType |= MOUSE_HANDLING_MIDDLE_BUTTON;
|
||||
}
|
||||
if (type == MouseEvent3D.RIGHT_CLICK || type == MouseEvent3D.RIGHT_MOUSE_DOWN || type == MouseEvent3D.RIGHT_MOUSE_UP) {
|
||||
mouseHandlingType |= MOUSE_HANDLING_RIGHT_BUTTON;
|
||||
}
|
||||
}
|
||||
if (vector.indexOf(listener) < 0) {
|
||||
vector.push(listener);
|
||||
@@ -796,6 +803,9 @@ package alternativa.engine3d.core {
|
||||
if (type == MouseEvent3D.MIDDLE_CLICK || type == MouseEvent3D.MIDDLE_MOUSE_DOWN || type == MouseEvent3D.MIDDLE_MOUSE_UP) {
|
||||
mouseHandlingType &= ~MOUSE_HANDLING_MIDDLE_BUTTON;
|
||||
}
|
||||
if (type == MouseEvent3D.RIGHT_CLICK || type == MouseEvent3D.RIGHT_MOUSE_DOWN || type == MouseEvent3D.RIGHT_MOUSE_UP) {
|
||||
mouseHandlingType &= ~MOUSE_HANDLING_RIGHT_BUTTON;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ package alternativa.engine3d.core {
|
||||
private var targetDepth:Number;
|
||||
private var pressedTarget:Object3D;
|
||||
private var pressedMiddleTarget:Object3D;
|
||||
private var pressedRightTarget:Object3D;
|
||||
private var clickedTarget:Object3D;
|
||||
private var overedTarget:Object3D;
|
||||
private var overedTargetSurface:Surface;
|
||||
@@ -173,6 +174,7 @@ package alternativa.engine3d.core {
|
||||
private var _logoHorizontalMargin:Number = 0;
|
||||
private var _logoVerticalMargin:Number = 0;
|
||||
private var _renderToBitmap:Boolean;
|
||||
private var _rightClick3DEnabled:Boolean = false;
|
||||
|
||||
/**
|
||||
* Creates a <code>View</code> object.
|
||||
@@ -296,8 +298,6 @@ package alternativa.engine3d.core {
|
||||
// Listeners
|
||||
addEventListener(MouseEvent.MOUSE_DOWN, onMouse);
|
||||
addEventListener(MouseEvent.CLICK, onMouse);
|
||||
// addEventListener("rightMouseDown", onMouse);
|
||||
// addEventListener("rightClick", onMouse);
|
||||
addEventListener("middleMouseDown", onMouse);
|
||||
addEventListener("middleClick", onMouse);
|
||||
addEventListener(MouseEvent.DOUBLE_CLICK, onMouse);
|
||||
@@ -309,6 +309,26 @@ package alternativa.engine3d.core {
|
||||
addEventListener(Event.REMOVED_FROM_STAGE, onRemoveFromStage);
|
||||
}
|
||||
|
||||
public function get rightClick3DEnabled():Boolean {
|
||||
return _rightClick3DEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public function set rightClick3DEnabled(value:Boolean):void {
|
||||
if (value != _rightClick3DEnabled) {
|
||||
if (value) {
|
||||
addEventListener("rightMouseDown", onMouse);
|
||||
addEventListener("rightClick", onMouse);
|
||||
} else {
|
||||
removeEventListener("rightMouseDown", onMouse);
|
||||
removeEventListener("rightClick", onMouse);
|
||||
}
|
||||
_rightClick3DEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
private function onMouse(mouseEvent:MouseEvent):void {
|
||||
var prev:int = eventsLength - 1;
|
||||
// case of mouseMove repeats
|
||||
@@ -375,7 +395,7 @@ package alternativa.engine3d.core {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
alternativa3d function calculateRays(camera:Camera3D, processMoving:Boolean, processPressing:Boolean, processMouseWheel:Boolean, processMiddleButton:Boolean):void {
|
||||
alternativa3d function calculateRays(camera:Camera3D, processMoving:Boolean, processPressing:Boolean, processMouseWheel:Boolean, processMiddleButton:Boolean, processRightButton:Boolean):void {
|
||||
var i:int;
|
||||
var mouseEvent:MouseEvent;
|
||||
// Case of last coordinates fits in the view.
|
||||
@@ -414,6 +434,11 @@ package alternativa.engine3d.core {
|
||||
if (!processMiddleButton) {
|
||||
pressedMiddleTarget = null;
|
||||
}
|
||||
// Mask with rightClick3DEnabled for case when in the list there are old events witch dispatched before rightClick3DEnabled was made false
|
||||
processRightButton &&= _rightClick3DEnabled;
|
||||
if (!processRightButton) {
|
||||
pressedRightTarget = null;
|
||||
}
|
||||
|
||||
// Creation of exclusive rays
|
||||
var mouseX:Number = 1e+22;
|
||||
@@ -434,6 +459,9 @@ package alternativa.engine3d.core {
|
||||
if (!processMiddleButton && (mouseEvent.type == "middleMouseDown" || mouseEvent.type == "middleClick")) {
|
||||
continue;
|
||||
}
|
||||
if (!processRightButton && (mouseEvent.type == "rightMouseDown" || mouseEvent.type == "rightClick")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mouseEvent.type != "mouseOut") {
|
||||
// Calculation of ray within the camera
|
||||
@@ -652,24 +680,23 @@ package alternativa.engine3d.core {
|
||||
}
|
||||
pressedMiddleTarget = null;
|
||||
break;
|
||||
// case "rightMouseDown":
|
||||
// defineTarget(index);
|
||||
// if (target != null) {
|
||||
// propagateEvent(MouseEvent3D.RIGHT_MOUSE_DOWN, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
// }
|
||||
// pressedTarget = target;
|
||||
// break;
|
||||
// case "rightClick":
|
||||
// defineTarget(index);
|
||||
// if (target != null) {
|
||||
// propagateEvent(MouseEvent3D.RIGHT_MOUSE_UP, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
// if (pressedTarget == target) {
|
||||
// clickedTarget = target;
|
||||
// propagateEvent(MouseEvent3D.RIGHT_CLICK, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
// }
|
||||
// }
|
||||
// pressedTarget = null;
|
||||
// break;
|
||||
case "rightMouseDown":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
propagateEvent(MouseEvent3D.RIGHT_MOUSE_DOWN, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
}
|
||||
pressedRightTarget = target;
|
||||
break;
|
||||
case "rightClick":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
propagateEvent(MouseEvent3D.RIGHT_MOUSE_UP, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
if (pressedRightTarget == target) {
|
||||
propagateEvent(MouseEvent3D.RIGHT_CLICK, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
}
|
||||
}
|
||||
pressedRightTarget = null;
|
||||
break;
|
||||
case "mouseMove":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
|
||||
@@ -46,23 +46,23 @@ package alternativa.engine3d.core.events {
|
||||
*/
|
||||
public static const MOUSE_UP:String = "mouseUp3D";
|
||||
|
||||
// /**
|
||||
// * Defines the value of the <code>type</code> property of a <code>rightClick3D</code> event object.
|
||||
// * @eventType rightClick3D
|
||||
// */
|
||||
// public static const RIGHT_CLICK:String = "rightClick3D";
|
||||
//
|
||||
// /**
|
||||
// * Defines the value of the <code>type</code> property of a <code>rightMouseDown3D</code> event object.
|
||||
// * @eventType rightMouseDown3D
|
||||
// */
|
||||
// public static const RIGHT_MOUSE_DOWN:String = "rightMouseDown3D";
|
||||
//
|
||||
// /**
|
||||
// * Defines the value of the <code>type</code> property of a <code>rightMouseUp3D</code> event object.
|
||||
// * @eventType rightMouseUp3D
|
||||
// */
|
||||
// public static const RIGHT_MOUSE_UP:String = "rightMouseUp3D";
|
||||
/**
|
||||
* Defines the value of the <code>type</code> property of a <code>rightClick3D</code> event object.
|
||||
* @eventType rightClick3D
|
||||
*/
|
||||
public static const RIGHT_CLICK:String = "rightClick3D";
|
||||
|
||||
/**
|
||||
* Defines the value of the <code>type</code> property of a <code>rightMouseDown3D</code> event object.
|
||||
* @eventType rightMouseDown3D
|
||||
*/
|
||||
public static const RIGHT_MOUSE_DOWN:String = "rightMouseDown3D";
|
||||
|
||||
/**
|
||||
* Defines the value of the <code>type</code> property of a <code>rightMouseUp3D</code> event object.
|
||||
* @eventType rightMouseUp3D
|
||||
*/
|
||||
public static const RIGHT_MOUSE_UP:String = "rightMouseUp3D";
|
||||
|
||||
/**
|
||||
* Defines the value of the <code>type</code> property of a <code>middleClick3D</code> event object.
|
||||
|
||||
Reference in New Issue
Block a user