diff options
| author | jmoenig <jens@moenig.org> | 2013-06-25 09:46:21 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-06-25 09:46:21 +0200 |
| commit | 9c6b2a3e6f152d8f2cc67f450b267ddca358a788 (patch) | |
| tree | 27d7def94e2bd7cd7ed5de6465ff8a80c65ba565 /widgets.js | |
| parent | 416d92d78b4e72fc9c3ccbc41c1ef98874d7e500 (diff) | |
| download | snap-yow-9c6b2a3e6f152d8f2cc67f450b267ddca358a788.tar.gz snap-yow-9c6b2a3e6f152d8f2cc67f450b267ddca358a788.zip | |
code mapping: dialog input is now multi-line monospaced
Diffstat (limited to 'widgets.js')
| -rw-r--r-- | widgets.js | 63 |
1 files changed, 61 insertions, 2 deletions
@@ -71,9 +71,10 @@ /*global TriggerMorph, modules, Color, Point, BoxMorph, radians, newCanvas, StringMorph, Morph, TextMorph, nop, detect, StringFieldMorph, 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 ToggleButtonMorph; @@ -1675,6 +1676,64 @@ DialogBoxMorph.prototype.prompt = function ( 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 ( title, purpose, |
