kopia lustrzana https://github.com/backface/turtlestitch
Merge pull request #1250 from bromagosa/live-boolean-inputs
Implements execute on change for boolean togglesdev
commit
61dec93ede
67
blocks.js
67
blocks.js
|
@ -5799,6 +5799,40 @@ ArgMorph.prototype.init = function (type, 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.prototype.justDropped = function () {
|
||||
|
@ -6934,10 +6968,6 @@ InputSlotMorph.prototype = new ArgMorph();
|
|||
InputSlotMorph.prototype.constructor = InputSlotMorph;
|
||||
InputSlotMorph.uber = ArgMorph.prototype;
|
||||
|
||||
// InputSlotMorph preferences settings:
|
||||
|
||||
InputSlotMorph.prototype.executeOnSliderEdit = false;
|
||||
|
||||
// InputSlotMorph instance creation:
|
||||
|
||||
function InputSlotMorph(text, isNumeric, choiceDict, isReadOnly) {
|
||||
|
@ -7516,33 +7546,6 @@ InputSlotMorph.prototype.reactToEdit = function () {
|
|||
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.prototype.userMenu = function () {
|
||||
|
@ -8082,6 +8085,7 @@ BooleanSlotMorph.prototype.toggleValue = function () {
|
|||
|
||||
BooleanSlotMorph.prototype.mouseClickLeft = function () {
|
||||
this.toggleValue();
|
||||
this.reactToSliderEdit();
|
||||
};
|
||||
|
||||
BooleanSlotMorph.prototype.mouseEnter = function () {
|
||||
|
@ -8104,6 +8108,7 @@ BooleanSlotMorph.prototype.mouseLeave = function () {
|
|||
this.changed();
|
||||
};
|
||||
|
||||
|
||||
// BooleanSlotMorph drawing:
|
||||
|
||||
BooleanSlotMorph.prototype.drawNew = function (progress) {
|
||||
|
|
6
gui.js
6
gui.js
|
@ -2356,7 +2356,7 @@ IDE_Morph.prototype.settingsMenu = function () {
|
|||
addPreference(
|
||||
'Execute on slider change',
|
||||
'toggleSliderExecute',
|
||||
InputSlotMorph.prototype.executeOnSliderEdit,
|
||||
ArgMorph.prototype.executeOnSliderEdit,
|
||||
'uncheck to supress\nrunning scripts\nwhen moving the slider',
|
||||
'check to run\nthe edited script\nwhen moving the slider'
|
||||
);
|
||||
|
@ -4163,8 +4163,8 @@ IDE_Morph.prototype.toggleInputSliders = function () {
|
|||
};
|
||||
|
||||
IDE_Morph.prototype.toggleSliderExecute = function () {
|
||||
InputSlotMorph.prototype.executeOnSliderEdit =
|
||||
!InputSlotMorph.prototype.executeOnSliderEdit;
|
||||
ArgMorph.prototype.executeOnSliderEdit =
|
||||
!ArgMorph.prototype.executeOnSliderEdit;
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.toggleAppMode = function (appMode) {
|
||||
|
|
Ładowanie…
Reference in New Issue