From 5b63e7e6fa009fca3cbb8eaf2fc7e629f17d7845 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 25 Oct 2013 15:14:20 +0200 Subject: enable Symbols in InputSlotDialog Morph’s drop down menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- byob.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'byob.js') diff --git a/byob.js b/byob.js index 6815732..921c3d1 100644 --- a/byob.js +++ b/byob.js @@ -2296,6 +2296,7 @@ InputSlotDialogMorph.prototype.init = function ( // additional properties: this.fragment = fragment || new BlockLabelFragment(); + this.textfield = null; this.types = null; this.slots = null; this.isExpanded = false; @@ -2397,6 +2398,8 @@ InputSlotDialogMorph.prototype.addBlockTypeButton = BlockDialogMorph.prototype.addBlockTypeButton; InputSlotDialogMorph.prototype.setType = function (fragmentType) { + this.textfield.choices = fragmentType ? null : this.symbolMenu; + this.textfield.drawNew(); this.fragment.type = fragmentType || null; this.types.children.forEach(function (c) { c.refresh(); @@ -2487,6 +2490,7 @@ InputSlotDialogMorph.prototype.open = function ( var txt = new InputFieldMorph(defaultString), oldFlag = Morph.prototype.trackChanges; + txt.choices = this.symbolMenu; Morph.prototype.trackChanges = false; this.isExpanded = this.isLaunchingExpanded; txt.setWidth(250); @@ -2495,6 +2499,7 @@ InputSlotDialogMorph.prototype.open = function ( if (pic) {this.setPicture(pic); } this.addBody(txt); txt.drawNew(); + this.textfield = txt; this.addButton('ok', 'OK'); if (!noDeleteButton) { this.addButton('deleteFragment', 'Delete'); @@ -2509,6 +2514,19 @@ InputSlotDialogMorph.prototype.open = function ( this.changed(); }; +InputSlotDialogMorph.prototype.symbolMenu = function () { + var symbols = [], + symbolColor = new Color(100, 100, 130), + myself = this; + SymbolMorph.prototype.names.forEach(function (symbol) { + symbols.push([ + [new SymbolMorph(symbol, myself.fontSize, symbolColor), symbol], + '$' + symbol + ]); + }); + return symbols; +}; + InputSlotDialogMorph.prototype.deleteFragment = function () { this.fragment.isDeleted = true; this.accept(); -- cgit v1.3.1