summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--byob.js10
-rw-r--r--gui.js13
-rwxr-xr-xhistory.txt4
-rw-r--r--widgets.js30
4 files changed, 27 insertions, 30 deletions
diff --git a/byob.js b/byob.js
index ffcc349..1dc1f2b 100644
--- a/byob.js
+++ b/byob.js
@@ -105,7 +105,7 @@ CommentMorph, localize, CSlotMorph, SpeechBubbleMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.byob = '2013-April-23';
+modules.byob = '2013-April-24';
// Declarations
@@ -1026,10 +1026,6 @@ BlockDialogMorph.prototype = new DialogBoxMorph();
BlockDialogMorph.prototype.constructor = BlockDialogMorph;
BlockDialogMorph.uber = DialogBoxMorph.prototype;
-// BlockDialogMorph constants:
-
-BlockDialogMorph.prototype.key = 'makeABlock';
-
// BlockDialogMorph instance creation:
function BlockDialogMorph(target, action, environment) {
@@ -1053,6 +1049,8 @@ BlockDialogMorph.prototype.init = function (target, action, environment) {
);
// override inherited properites:
+ this.key = 'makeABlock';
+
this.types = new AlignmentMorph('row', this.padding);
this.add(this.types);
this.scopes = new AlignmentMorph('row', this.padding);
@@ -1079,6 +1077,7 @@ BlockDialogMorph.prototype.openForChange = function (
preventTypeChange // <bool>
) {
var clr = SpriteMorph.prototype.blockColor[category];
+ this.key = 'changeABlock';
this.category = category;
this.blockType = type;
@@ -1481,6 +1480,7 @@ BlockEditorMorph.prototype.init = function (definition, target) {
);
// override inherited properites:
+ this.key = 'editBlock' + definition.spec;
this.labelString = 'Block Editor';
this.createLabel();
diff --git a/gui.js b/gui.js
index 12897ad..8ac5234 100644
--- a/gui.js
+++ b/gui.js
@@ -68,7 +68,7 @@ sb, CommentMorph, CommandBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.gui = '2013-April-23';
+modules.gui = '2013-April-24';
// Declarations
@@ -3007,7 +3007,7 @@ IDE_Morph.prototype.initializeCloud = function () {
myself.cloudError()
);
}
- ).withKey('cloud').promptCredentials(
+ ).withKey('cloudlogin').promptCredentials(
'Sign in',
'login',
null,
@@ -3048,7 +3048,7 @@ IDE_Morph.prototype.createCloudAccount = function () {
myself.cloudError()
);
}
- ).withKey('cloud').promptCredentials(
+ ).withKey('cloudsignup').promptCredentials(
'Sign up',
'signup',
'http://snap.berkeley.edu/tos.html',
@@ -3078,7 +3078,7 @@ IDE_Morph.prototype.changeCloudPassword = function () {
myself.cloudError()
);
}
- ).withKey('cloud').promptCredentials(
+ ).withKey('cloudpassword').promptCredentials(
'Change Password',
'changePassword',
null,
@@ -3403,10 +3403,6 @@ ProjectDialogMorph.prototype = new DialogBoxMorph();
ProjectDialogMorph.prototype.constructor = ProjectDialogMorph;
ProjectDialogMorph.uber = DialogBoxMorph.prototype;
-// ProjectDialogMorph constants:
-
-ProjectDialogMorph.prototype.key = 'project';
-
// ProjectDialogMorph instance creation:
function ProjectDialogMorph(ide, label) {
@@ -3444,6 +3440,7 @@ ProjectDialogMorph.prototype.init = function (ide, task) {
// override inherited properites:
this.labelString = this.task === 'save' ? 'Save Project' : 'Open Project';
this.createLabel();
+ this.key = 'project' + task;
// build contents
this.buildContents();
diff --git a/history.txt b/history.txt
index 7ef0d44..8b7aa5f 100755
--- a/history.txt
+++ b/history.txt
@@ -1659,3 +1659,7 @@ ______
* Lists, Objects: Circularity no longer breaks watchers
* Widgets: Multiple Dialogs of the same kind are prevented except for a few (e.g. BlockEditor). Thanks for this fix, Nathan! (and for the many little UI things you've fixed as well)
* German translation update
+
+130424
+------
+* Widgets, BYOB, GUI: prevent multiple block editors on the same block definition, allow multiple dialogs on different objects, handle dialog instances in DialogBoxMorph.prototype
diff --git a/widgets.js b/widgets.js
index 2cb8bc4..4c720a9 100644
--- a/widgets.js
+++ b/widgets.js
@@ -73,7 +73,7 @@ newCanvas, StringMorph, Morph, TextMorph, nop, detect, StringFieldMorph,
HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph,
ArrowMorph, MenuMorph, isString, isNil, SliderMorph*/
-modules.widgets = '2013-April-23';
+modules.widgets = '2013-April-24';
var PushButtonMorph;
var ToggleButtonMorph;
@@ -1396,10 +1396,8 @@ ToggleElementMorph.prototype.mouseClickLeft
Note:
-----
- I add a property "dialogs" to whichever World I'm popped up in, which
- keeps track of my instances, preventing double instances of the same type
- and on the same objects, while allowing multiple instance where
- appropriate
+ my key property keeps track of my purpose to prevent multiple instances
+ on the same or similar objects
*/
// DialogBoxMorph inherits from Morph:
@@ -1435,6 +1433,7 @@ DialogBoxMorph.prototype.buttonOutlineColor
= PushButtonMorph.prototype.color;
DialogBoxMorph.prototype.buttonOutlineGradient = true;
+DialogBoxMorph.prototype.instances = {}; // prevent multiple instances
// DialogBoxMorph instance creation:
@@ -1447,7 +1446,6 @@ DialogBoxMorph.prototype.init = function (target, action, environment) {
this.target = target || null;
this.action = action || null;
this.environment = environment || null;
- this.popUpWorld = null; // keep track of open instances per world
this.key = null; // keep track of my purpose to prevent mulitple instances
this.labelString = null;
@@ -1488,7 +1486,7 @@ DialogBoxMorph.prototype.inform = function (
);
if (!this.key) {
- this.key = 'information';
+ this.key = 'inform' + title + textString;
}
this.labelString = title;
@@ -1523,7 +1521,7 @@ DialogBoxMorph.prototype.askYesNo = function (
);
if (!this.key) {
- this.key = 'prompt';
+ this.key = 'decide' + title + textString;
}
this.labelString = title;
@@ -1626,7 +1624,7 @@ DialogBoxMorph.prototype.prompt = function (
this.createLabel();
if (!this.key) {
- this.key = 'prompt';
+ this.key = 'prompt' + title + defaultString;
}
this.addBody(txt);
@@ -1994,7 +1992,7 @@ DialogBoxMorph.prototype.promptCredentials = function (
this.reactToChoice(); // initialize e-mail label
if (!this.key) {
- this.key = 'prompt';
+ this.key = 'credentials' + title + purpose;
}
this.popUp(world);
@@ -2045,13 +2043,11 @@ DialogBoxMorph.prototype.withKey = function (key) {
DialogBoxMorph.prototype.popUp = function (world) {
if (world) {
if (this.key) {
- if (!world.dialogs) {world.dialogs = {}; } // lazy init
- if (world.dialogs[this.key]) {
- world.dialogs[this.key].destroy();
+ if (this.instances[this.key]) {
+ this.instances[this.key].destroy();
}
- world.dialogs[this.key] = this;
+ this.instances[this.key] = this;
}
- this.popUpWorld = world;
world.add(this);
world.keyboardReceiver = this;
this.setCenter(world.center());
@@ -2061,8 +2057,8 @@ DialogBoxMorph.prototype.popUp = function (world) {
DialogBoxMorph.prototype.destroy = function () {
DialogBoxMorph.uber.destroy.call(this);
- if (this.key && this.popUpWorld && this.popUpWorld.dialogs) {
- this.popUpWorld.dialogs[this.key] = undefined;
+ if (this.key) {
+ delete this.instances[this.key];
}
};