summaryrefslogtreecommitdiff
path: root/morphic.js
diff options
context:
space:
mode:
authorMichael Ball <cycomachead@gmail.com>2014-11-21 03:08:41 -0800
committerMichael Ball <cycomachead@gmail.com>2014-11-21 03:08:41 -0800
commit3e8146d043b1f1dc6f37e0a8cbd2e5d3dafb90c7 (patch)
tree0a36d8b40781b5c3adc38c382cd866bbd7499598 /morphic.js
parentdbf2e6665b4ff7ef8cb863bcfef5939117a2f795 (diff)
parentf2d0c2eba5d6b012fc3fb1167c82b64b2f8ed447 (diff)
downloadsnap-3e8146d043b1f1dc6f37e0a8cbd2e5d3dafb90c7.tar.gz
snap-3e8146d043b1f1dc6f37e0a8cbd2e5d3dafb90c7.zip
Merge in recent changes (split block improvements #619)
Diffstat (limited to 'morphic.js')
-rw-r--r--morphic.js37
1 files changed, 20 insertions, 17 deletions
diff --git a/morphic.js b/morphic.js
index 4e18482..763a196 100644
--- a/morphic.js
+++ b/morphic.js
@@ -464,9 +464,15 @@
MyMorph.prototype.mouseMove = function(pos) {};
- The only optional parameter of such a method is a Point object
+ All of these methods have as optional parameter a Point object
indicating the current position of the Hand inside the World's
- coordinate system.
+ coordinate system. The
+
+ mouseMove(pos, button)
+
+ event method has an additional optional parameter indicating the
+ currently pressed mouse button, which is either 'left' or 'right'.
+ You can use this to let users interact with 3D environments.
Events may be "bubbled" up a morph's owner chain by calling
@@ -1035,7 +1041,7 @@
/*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio,
FileList, getBlurredShadowSupport*/
-var morphicVersion = '2014-September-30';
+var morphicVersion = '2014-November-20';
var modules = {}; // keep track of additional loaded modules
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
@@ -5754,7 +5760,7 @@ SliderMorph.prototype.rangeSize = function () {
};
SliderMorph.prototype.ratio = function () {
- return this.size / this.rangeSize();
+ return this.size / (this.rangeSize() + 1);
};
SliderMorph.prototype.unitSize = function () {
@@ -9346,11 +9352,11 @@ HandMorph.prototype.init = function (aWorld) {
this.world = aWorld;
this.mouseButton = null;
this.mouseOverList = [];
- this.mouseDownMorph = null;
this.morphToGrab = null;
this.grabOrigin = null;
this.temporaries = [];
this.touchHoldTimeout = null;
+ this.contextMenuEnabled = false;
};
HandMorph.prototype.changed = function () {
@@ -9494,9 +9500,10 @@ HandMorph.prototype.drop = function () {
*/
HandMorph.prototype.processMouseDown = function (event) {
- var morph, expectedClick, actualClick;
+ var morph, actualClick;
this.destroyTemporaries();
+ this.contextMenuEnabled = true;
this.morphToGrab = null;
if (this.children.length !== 0) {
this.drop();
@@ -9529,15 +9536,9 @@ HandMorph.prototype.processMouseDown = function (event) {
if (event.button === 2 || event.ctrlKey) {
this.mouseButton = 'right';
actualClick = 'mouseDownRight';
- expectedClick = 'mouseClickRight';
} else {
this.mouseButton = 'left';
actualClick = 'mouseDownLeft';
- expectedClick = 'mouseClickLeft';
- }
- this.mouseDownMorph = morph;
- while (!this.mouseDownMorph[expectedClick]) {
- this.mouseDownMorph = this.mouseDownMorph.parent;
}
while (!morph[actualClick]) {
morph = morph.parent;
@@ -9596,7 +9597,7 @@ HandMorph.prototype.processMouseUp = function () {
expectedClick = 'mouseClickLeft';
} else {
expectedClick = 'mouseClickRight';
- if (this.mouseButton) {
+ if (this.mouseButton && this.contextMenuEnabled) {
context = morph;
contextMenu = context.contextMenu();
while ((!contextMenu) &&
@@ -9654,16 +9655,18 @@ HandMorph.prototype.processMouseMove = function (event) {
// mouseOverNew = this.allMorphsAtPointer();
mouseOverNew = this.morphAtPointer().allParents();
- if ((this.children.length === 0) &&
- (this.mouseButton === 'left')) {
+ if (!this.children.length && this.mouseButton) {
topMorph = this.morphAtPointer();
morph = topMorph.rootForGrab();
if (topMorph.mouseMove) {
- topMorph.mouseMove(pos);
+ topMorph.mouseMove(pos, this.mouseButton);
+ if (this.mouseButton === 'right') {
+ this.contextMenuEnabled = false;
+ }
}
// if a morph is marked for grabbing, just grab it
- if (this.morphToGrab) {
+ if (this.mouseButton === 'left' && this.morphToGrab) {
if (this.morphToGrab.isDraggable) {
morph = this.morphToGrab;
this.grab(morph);