kopia lustrzana https://github.com/backface/turtlestitch
Implements execute on change for boolean toggles
rodzic
9cd720d613
commit
37ba8dd000
67
blocks.js
67
blocks.js
|
@ -5799,6 +5799,40 @@ ArgMorph.prototype.init = function (type, silently) {
|
||||||
this.setExtent(new Point(50, 50), silently);
|
this.setExtent(new Point(50, 50), silently);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ArgMorph preferences settings:
|
||||||
|
|
||||||
|
ArgMorph.prototype.executeOnSliderEdit = false;
|
||||||
|
|
||||||
|
// ArgMorph events:
|
||||||
|
|
||||||
|
ArgMorph.prototype.reactToSliderEdit = function () {
|
||||||
|
/*
|
||||||
|
directly execute the stack of blocks I'm part of if my
|
||||||
|
"executeOnSliderEdit" setting is turned on, obeying the stage's
|
||||||
|
thread safety setting. This feature allows for "Bret Victor" style
|
||||||
|
interactive coding.
|
||||||
|
*/
|
||||||
|
var block, top, receiver, stage;
|
||||||
|
if (!this.executeOnSliderEdit) {return; }
|
||||||
|
block = this.parentThatIsA(BlockMorph);
|
||||||
|
if (block) {
|
||||||
|
top = block.topBlock();
|
||||||
|
receiver = top.receiver();
|
||||||
|
if (top instanceof PrototypeHatBlockMorph) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (receiver) {
|
||||||
|
stage = receiver.parentThatIsA(StageMorph);
|
||||||
|
if (stage && stage.isThreadSafe) {
|
||||||
|
stage.threads.startProcess(top, stage.isThreadSafe);
|
||||||
|
} else {
|
||||||
|
top.mouseClickLeft();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// ArgMorph drag & drop: for demo puposes only
|
// ArgMorph drag & drop: for demo puposes only
|
||||||
|
|
||||||
ArgMorph.prototype.justDropped = function () {
|
ArgMorph.prototype.justDropped = function () {
|
||||||
|
@ -6934,10 +6968,6 @@ InputSlotMorph.prototype = new ArgMorph();
|
||||||
InputSlotMorph.prototype.constructor = InputSlotMorph;
|
InputSlotMorph.prototype.constructor = InputSlotMorph;
|
||||||
InputSlotMorph.uber = ArgMorph.prototype;
|
InputSlotMorph.uber = ArgMorph.prototype;
|
||||||
|
|
||||||
// InputSlotMorph preferences settings:
|
|
||||||
|
|
||||||
InputSlotMorph.prototype.executeOnSliderEdit = false;
|
|
||||||
|
|
||||||
// InputSlotMorph instance creation:
|
// InputSlotMorph instance creation:
|
||||||
|
|
||||||
function InputSlotMorph(text, isNumeric, choiceDict, isReadOnly) {
|
function InputSlotMorph(text, isNumeric, choiceDict, isReadOnly) {
|
||||||
|
@ -7516,33 +7546,6 @@ InputSlotMorph.prototype.reactToEdit = function () {
|
||||||
this.contents().clearSelection();
|
this.contents().clearSelection();
|
||||||
};
|
};
|
||||||
|
|
||||||
InputSlotMorph.prototype.reactToSliderEdit = function () {
|
|
||||||
/*
|
|
||||||
directly execute the stack of blocks I'm part of if my
|
|
||||||
"executeOnSliderEdit" setting is turned on, obeying the stage's
|
|
||||||
thread safety setting. This feature allows for "Bret Victor" style
|
|
||||||
interactive coding.
|
|
||||||
*/
|
|
||||||
var block, top, receiver, stage;
|
|
||||||
if (!this.executeOnSliderEdit) {return; }
|
|
||||||
block = this.parentThatIsA(BlockMorph);
|
|
||||||
if (block) {
|
|
||||||
top = block.topBlock();
|
|
||||||
receiver = top.receiver();
|
|
||||||
if (top instanceof PrototypeHatBlockMorph) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (receiver) {
|
|
||||||
stage = receiver.parentThatIsA(StageMorph);
|
|
||||||
if (stage && stage.isThreadSafe) {
|
|
||||||
stage.threads.startProcess(top, stage.isThreadSafe);
|
|
||||||
} else {
|
|
||||||
top.mouseClickLeft();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// InputSlotMorph menu:
|
// InputSlotMorph menu:
|
||||||
|
|
||||||
InputSlotMorph.prototype.userMenu = function () {
|
InputSlotMorph.prototype.userMenu = function () {
|
||||||
|
@ -8082,6 +8085,7 @@ BooleanSlotMorph.prototype.toggleValue = function () {
|
||||||
|
|
||||||
BooleanSlotMorph.prototype.mouseClickLeft = function () {
|
BooleanSlotMorph.prototype.mouseClickLeft = function () {
|
||||||
this.toggleValue();
|
this.toggleValue();
|
||||||
|
this.reactToSliderEdit();
|
||||||
};
|
};
|
||||||
|
|
||||||
BooleanSlotMorph.prototype.mouseEnter = function () {
|
BooleanSlotMorph.prototype.mouseEnter = function () {
|
||||||
|
@ -8104,6 +8108,7 @@ BooleanSlotMorph.prototype.mouseLeave = function () {
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// BooleanSlotMorph drawing:
|
// BooleanSlotMorph drawing:
|
||||||
|
|
||||||
BooleanSlotMorph.prototype.drawNew = function (progress) {
|
BooleanSlotMorph.prototype.drawNew = function (progress) {
|
||||||
|
|
6
gui.js
6
gui.js
|
@ -2355,7 +2355,7 @@ IDE_Morph.prototype.settingsMenu = function () {
|
||||||
addPreference(
|
addPreference(
|
||||||
'Execute on slider change',
|
'Execute on slider change',
|
||||||
'toggleSliderExecute',
|
'toggleSliderExecute',
|
||||||
InputSlotMorph.prototype.executeOnSliderEdit,
|
ArgMorph.prototype.executeOnSliderEdit,
|
||||||
'uncheck to supress\nrunning scripts\nwhen moving the slider',
|
'uncheck to supress\nrunning scripts\nwhen moving the slider',
|
||||||
'check to run\nthe edited script\nwhen moving the slider'
|
'check to run\nthe edited script\nwhen moving the slider'
|
||||||
);
|
);
|
||||||
|
@ -4162,8 +4162,8 @@ IDE_Morph.prototype.toggleInputSliders = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.toggleSliderExecute = function () {
|
IDE_Morph.prototype.toggleSliderExecute = function () {
|
||||||
InputSlotMorph.prototype.executeOnSliderEdit =
|
ArgMorph.prototype.executeOnSliderEdit =
|
||||||
!InputSlotMorph.prototype.executeOnSliderEdit;
|
!ArgMorph.prototype.executeOnSliderEdit;
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.toggleAppMode = function (appMode) {
|
IDE_Morph.prototype.toggleAppMode = function (appMode) {
|
||||||
|
|
Ładowanie…
Reference in New Issue