kopia lustrzana https://github.com/backface/turtlestitch
code mapping: dialog input is now multi-line monospaced
rodzic
416d92d78b
commit
9c6b2a3e6f
|
@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.blocks = '2013-June-24';
|
modules.blocks = '2013-June-25';
|
||||||
|
|
||||||
var SyntaxElementMorph;
|
var SyntaxElementMorph;
|
||||||
var BlockMorph;
|
var BlockMorph;
|
||||||
|
@ -2201,7 +2201,7 @@ BlockMorph.prototype.mapToCode = function () {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
this
|
this
|
||||||
).prompt(
|
).promptCode(
|
||||||
'Code mapping',
|
'Code mapping',
|
||||||
key === 'evaluateCustomBlock' ? this.definition.codeMapping || ''
|
key === 'evaluateCustomBlock' ? this.definition.codeMapping || ''
|
||||||
: StageMorph.prototype.codeMappings[key] || '',
|
: StageMorph.prototype.codeMappings[key] || '',
|
||||||
|
@ -6388,7 +6388,7 @@ InputSlotMorph.prototype.mapToCode = function () {
|
||||||
StageMorph.prototype.codeMappings.string = code;
|
StageMorph.prototype.codeMappings.string = code;
|
||||||
},
|
},
|
||||||
this
|
this
|
||||||
).prompt(
|
).promptCode(
|
||||||
'Code mapping - String <#1>',
|
'Code mapping - String <#1>',
|
||||||
StageMorph.prototype.codeMappings.string || '',
|
StageMorph.prototype.codeMappings.string || '',
|
||||||
this.world()
|
this.world()
|
||||||
|
@ -8534,7 +8534,7 @@ MultiArgMorph.prototype.mapToCode = function (key, label) {
|
||||||
StageMorph.prototype.codeMappings[key] = code;
|
StageMorph.prototype.codeMappings[key] = code;
|
||||||
},
|
},
|
||||||
this
|
this
|
||||||
).prompt(
|
).promptCode(
|
||||||
'Code mapping - ' + label,
|
'Code mapping - ' + label,
|
||||||
StageMorph.prototype.codeMappings[key] || '',
|
StageMorph.prototype.codeMappings[key] || '',
|
||||||
this.world()
|
this.world()
|
||||||
|
|
|
@ -1757,3 +1757,7 @@ ______
|
||||||
130624
|
130624
|
||||||
------
|
------
|
||||||
* Objects, Blocks: pretty printing for mapped code, now supporting Python mappings
|
* Objects, Blocks: pretty printing for mapped code, now supporting Python mappings
|
||||||
|
|
||||||
|
130625
|
||||||
|
------
|
||||||
|
* Widgets, Blocks: code mapping dialog input is now multi-line monospaced
|
||||||
|
|
63
widgets.js
63
widgets.js
|
@ -71,9 +71,10 @@
|
||||||
/*global TriggerMorph, modules, Color, Point, BoxMorph, radians,
|
/*global TriggerMorph, modules, Color, Point, BoxMorph, radians,
|
||||||
newCanvas, StringMorph, Morph, TextMorph, nop, detect, StringFieldMorph,
|
newCanvas, StringMorph, Morph, TextMorph, nop, detect, StringFieldMorph,
|
||||||
HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph,
|
HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph,
|
||||||
ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences*/
|
ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences,
|
||||||
|
ScrollFrameMorph*/
|
||||||
|
|
||||||
modules.widgets = '2013-May-16';
|
modules.widgets = '2013-June-25';
|
||||||
|
|
||||||
var PushButtonMorph;
|
var PushButtonMorph;
|
||||||
var ToggleButtonMorph;
|
var ToggleButtonMorph;
|
||||||
|
@ -1675,6 +1676,64 @@ DialogBoxMorph.prototype.prompt = function (
|
||||||
this.popUp(world);
|
this.popUp(world);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DialogBoxMorph.prototype.promptCode = function (
|
||||||
|
title,
|
||||||
|
defaultString,
|
||||||
|
world,
|
||||||
|
pic
|
||||||
|
) {
|
||||||
|
var frame = new ScrollFrameMorph(),
|
||||||
|
text = new TextMorph(defaultString || ''),
|
||||||
|
size = pic ? Math.max(pic.width, 400) : 400;
|
||||||
|
|
||||||
|
this.getInput = function () {
|
||||||
|
return text.text;
|
||||||
|
};
|
||||||
|
|
||||||
|
frame.padding = 6;
|
||||||
|
frame.setWidth(size);
|
||||||
|
frame.acceptsDrops = false;
|
||||||
|
frame.contents.acceptsDrops = false;
|
||||||
|
|
||||||
|
text.fontName = 'monospace';
|
||||||
|
text.fontStyle = 'monospace';
|
||||||
|
text.fontSize = 11;
|
||||||
|
text.setPosition(frame.topLeft().add(frame.padding));
|
||||||
|
text.enableSelecting();
|
||||||
|
text.isEditable = true;
|
||||||
|
|
||||||
|
frame.setHeight(size / 4);
|
||||||
|
frame.fixLayout = nop;
|
||||||
|
frame.edge = InputFieldMorph.prototype.edge;
|
||||||
|
frame.fontSize = InputFieldMorph.prototype.fontSize;
|
||||||
|
frame.typeInPadding = InputFieldMorph.prototype.typeInPadding;
|
||||||
|
frame.contrast = InputFieldMorph.prototype.contrast;
|
||||||
|
frame.drawNew = InputFieldMorph.prototype.drawNew;
|
||||||
|
frame.drawRectBorder = InputFieldMorph.prototype.drawRectBorder;
|
||||||
|
|
||||||
|
frame.addContents(text);
|
||||||
|
text.drawNew();
|
||||||
|
|
||||||
|
if (pic) {this.setPicture(pic); }
|
||||||
|
|
||||||
|
this.labelString = title;
|
||||||
|
this.createLabel();
|
||||||
|
|
||||||
|
if (!this.key) {
|
||||||
|
this.key = 'promptCode' + title + defaultString;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addBody(frame);
|
||||||
|
frame.drawNew();
|
||||||
|
this.addButton('ok', 'OK');
|
||||||
|
this.addButton('cancel', 'Cancel');
|
||||||
|
this.fixLayout();
|
||||||
|
this.drawNew();
|
||||||
|
this.fixLayout();
|
||||||
|
this.popUp(world);
|
||||||
|
text.edit();
|
||||||
|
};
|
||||||
|
|
||||||
DialogBoxMorph.prototype.promptCredentials = function (
|
DialogBoxMorph.prototype.promptCredentials = function (
|
||||||
title,
|
title,
|
||||||
purpose,
|
purpose,
|
||||||
|
|
Ładowanie…
Reference in New Issue