Lively Kernel canvas
//
DraftingTextMorphbehavior40
1.clickonTextMorphshould"selectmorph"2.doubleclickshouldenableediting161
HelloWorld.Barfalse0
6%5true
tryoutthenewbehaviorinanobject-specificscope
TODO:Howcanwedistinguishcklicksfromdoubleclicks....?
100017.01744104826289Wikicontroltrue
nulltruecreateLayer("TextMorphDraftLayer");//enableLayer(TextMorphDraftLayer);//disableLayer(TextMorphDraftLayer);layerClass(TextMorphDraftLayer,TextMorph,{handlesMouseDown:function(proceed,evt){returntrue},onKeyDown:function(proceed,evt){console.log("onKeyDown"+evt);if(evt.getKeyCode()==Event.KEY_TAB){console.log("tab");varcursor=this.selectionRange[0];varlastChar=this.textString.substring(cursor-1,cursor);console.log("lastchar:"+lastChar)if(lastChar=="."){varlastWordRange=this.locale.selectWord(this.textString,cursor-1)varlastWord=this.textString.substring(lastWordRange[0],lastWordRange[1])//Worldvarchoices=["Hello","World","Foo","Bar"]if(!this.tabReplaceListIndex)this.tabReplaceListIndex=0;varreplace=choices[this.tabReplaceListIndex];this.tabReplaceListIndex=(this.tabReplaceListIndex+1)%choices.size();this.replaceSelectionfromKeyboard(replace);this.setSelectionRange(cursor,cursor+replace.size());}else{this.replaceSelectionfromKeyboard("\t");}evt.stop();return}returnproceed(evt)},onMouseDown:function(proceed,evt){console.log("onMouseDown"+evt);returnproceed(evt)},})truetruefalsetrue
4truetruefalse
false1truefalsetruetruefalse
nullfalsetruenullfalse
falsenullfalse
false
false
falsenullfalsefalsenullnullnullnullfalse
null60