Lively Kernel canvas
//
DraftNewPromptDialog40
WeneedabetterPromptDialogthatscaleswell...Sowetryoutthetheconnectmechanism18
-----falsetruefalse0
fontCourier12:spacewidth7from21xWidth7falsetruefalse0
worldis1:WorldMorph([[0,0,2000,1200]])falsetruefalse0
startingWikiNavigatorfalsetruefalse0
status207onPROPFINDhttp://lively-kernel.org/repository/webwerkstatt/draft/DraftPromptDialog.xhtmlfalsetruefalse0
http://lively-kernel.org/repository/webwerkstatt/draft/../anonymous_module_3loadedin176msfalsetruefalse0
http://lively-kernel.org/repository/webwerkstatt/draft/../anonymous_module_2loadedin1356msfalsetruefalse0
fontHelvetica40:spacewidth11from51xWidth20falsetruefalse0
fontHelvetica18:spacewidth5from23xWidth9falsetruefalse0
fitWidthfailureonTextMorph.getCharBoundsfalsetruefalse0
fitWidthfailureonTextMorph.getCharBoundsfalsetruefalse0
ResizingSVGcanvasfalsetruefalse0
Moduleloadcheckdone.30modulesloaded.falsetruefalse0
onAcceptFiredsfffalsetruefalse0
-------------------------------------------falsetruefalse0
invoke133356:ScriptableButtonMorph([[0,0,70,30]])falsetruefalse0
-------------------------------------------falsetruefalse0
invoke133356:ScriptableButtonMorph([[0,0,70,30]])falsetruefalse0
Hello2falsetruefalse0
-------------------------------------------falsetruefalse0
invoke133356:ScriptableButtonMorph([[0,0,70,30]])falsetruefalse0
-------------------------------------------falsetruefalse0
invoke1:WorldMorph([[0,0,2000,1200]])falsetruefalse0
status200onGEThttp://lively-kernel.org/repository/webwerkstatt/draft/DraftPromptDialog.xhtmlfalsetruefalse0
extendForSerializationundefinedfalsetruefalse0865
-1nullnulltrue0falsetruetruefalse
false1truefalse
nullfalse
nullfalse
nullfalse
nullfalsefalsetruetruefalse
truetrue100false
truefalse050
nullfalsetruenullfalse
Consolefalsenullfalse
false
false
falsenullfalsefalsenullnullnullnullfalse
HelloWorldfalsenullfalsetruenull
ButtonMorph.addMethods({initialize:function($super,initialBounds){this.baseFill=null;$super(initialBounds);this.value=false;//forconnect()this.isActive=true;if(Config.selfConnect){varmodel=Record.newNodeInstance({Value:this.value,IsActive:this.isActive});//thisdefaultselfconnectionmaygetoverwrittenby,eg,connectModel()...this.relayToModel(model,{Value:"Value",IsActive:"IsActive"});}//Stylingthis.applyLinkedStyles();this.changeAppearanceFor(this.value);returnthis;},})21truetruefalsetruetruefalse
false1truefalsetruetruefalse
nullfalsetruenullfalse
falsenullfalse
false
false
falsenullfalsefalsenullnullnullnullfalse
/**ReplacementforPromptDialogWidget**///TODO:getridofthemagicandrepetitivelayoutnumbers....PanelMorph.subclass("PromptDialogMorph",{suppressHandles:true,initialize:function($super,extent){extent=extent||pt(300,100);$super(extent);this.layoutManager=newVerticalLayout();this.textPane=newTextPane(newRectangle(0,0,300,100),"");this.textPane.applyStyle({fill:Color.white});this.textPane.innerMorph().applyStyle({fill:null});this.textPane.innerMorph().owner.applyStyle({fill:null});//clipthis.addMorph(this.textPane);this.okButton=newButtonMorph(newRectangle(0,0,70,20));this.okButton.setLabel("OK");connect(this.okButton,"value",this,'onAcceptButtonChanged');connect(this,"onaccept",this,'onAcceptFired');this.cancelButton=newButtonMorph(newRectangle(0,0,70,20));this.cancelButton.setLabel("Cancel");connect(this.cancelButton,"value",this,'onCancelButtonChanged');connect(this,"oncancel",this,'onCancelFired');varpane=newBoxMorph();pane.layoutManager=newHorizontalLayout();pane.padding=newRectangle(5,5,5,5);pane.addMorph(this.cancelButton);pane.addMorph(this.okButton);pane.setBounds(pane.submorphBounds(true));pane.setFill(null);this.addMorph(pane);this.buttonPane=pane;this.title="PromptDialog"this.linkToStyles(["panel"]);this.adjustForNewBounds();},setText:function(aString){this.textPane.innerMorph().setTextString(aString);},getText:function(){returnthis.textPane.innerMorph().textString},onAcceptButtonChanged:function(value){if(!value){updateAttributeConnection(this,'onaccept',this.getText());this.removeWithWindow();}},onCancelButtonChanged:function(value){if(!value){updateAttributeConnection(this,'oncancel');this.removeWithWindow();}},adjustForNewBounds:function($super){varnewExtent=this.innerBounds().extent();varoffset=pt(5,this.buttonPane.getExtent().y+15);this.textPane.setExtent(newExtent.subPt(offset))this.relayout();//moveButtonsvaroffset=this.shape.bounds().bottomRight().subPt(this.buttonPane.bounds().bottomRight())this.buttonPane.moveBy(offset.subPt(pt(5,5)))},openIn:function(world,loc){varwin=world.addFramedMorph(this,this.title,loc);returnwin;},removeWithWindow:function(view){if(this.owner&&(this.ownerinstanceofWindowMorph)){this.owner.remove()}else{this.remove()}},})Morph.addMethods({relayout:function(){varmorphs=this.submorphs.clone();varself=this;morphs.each(function(ea){ea.remove()});morphs.each(function(ea){self.addMorph(ea)});},})createLayer("DraftPromptLayer");layerClass(DraftPromptLayer,WorldMorph,{prompt:function(proceed,message,callback,defaultInput){vardialog=newPromptDialogMorph();dialog.title=message;dialog.setText(defaultInput);dialog.onAcceptFired=callback;dialog.openIn(this,this.positionForNewMorph());},})enableLayer(DraftPromptLayer);//disableLayer(DraftPromptLayer);Morph.subclass("PromptDialogMorphExampleClientMorph",{oncancel:function(){console.log("oncancel")},onaccept:function(input){console.log("onAcceptFired"+input);}})Object.extend(PromptDialogMorph,{openExample:function(){if($morph('testPromptDialog'))$morph('testPromptDialog').remove();varmorph=newPromptDialogMorph();//morph.openInWorld();varwin=morph.openIn(WorldMorph.current(),pt(550,50));win.setExtent(pt(300,300))win.name='testPromptDialog';//weneedobjectsthatarepersistentandimplementthebehaviorvarclient=newPromptDialogMorphExampleClientMorph(newlively.scene.Rectangle(0,0,1,1));morph.addMorph(client);//storeitsomewhereconnect(morph,'oncancel',client,'oncancel');connect(morph,'onaccept',client,'onaccept');}})PromptDialogMorph.openExample();//this.world().prompt("Howoldareyou?",function(answer){alert("Nextyearyoubecome"+(Number(answer)+1))})truetruefalse163truetruefalse
false1truefalsetruetruefalse
nullfalsetruenullfalse
falsenullfalse
false
false
falsenullfalsefalsenullnullnullnullfalse
nulltruetesttruetruefalsetruetruefalse
false1truefalsetruetruefalse
Cancelfalsenullfalsefalsetrue
false
OKfalsenullfalse
truenullfalsetrue
falsefalsenull
false
nullfalsetruenullfalse
worldfile(.xhtml)falsenullfalse
false
false
falsenullfalsefalsenullnullnullnullfalsenull72