cop.create("CiteLayer").refineClass(lively.morphic.Text, { followBibliographicReference: function() { alertOK("show reference " + this.currentBibliographicReference) }, onMouseUp: function(evt) { var s = this.selectionString(); if (this.followCiteButton) this.followCiteButton.remove(); if (s.match(/[A-Z][a-z]+[0-9][0-9][0-9][0-9][A-Z]+/)) { this.currentBibliographicReference = s; var b = new lively.morphic.Button(new Rectangle(0,0,50,20), "show") b.isEpiMorph = true; lively.bindings.connect(b, 'fire', this, 'followBibliographicReference') this.addMorph(b) b.align( b.getBounds().bottomLeft(), this.localize(this.getSelectionBounds().topRight())); this.followCiteButton = b; } return cop.proceed(evt) } }) $morph('DevArea').setWithLayers([cop.create("CiteLayer")])
Example: Hello [Ungar1994SPS] World so what's up!
DevArea
Window
X
M