<html>
<style>
body{ prototype:Bar; }
div.block
{
behavior: edit;
}
div.block:focus {
background-color:bisque;
cursor: text;
}
</style>
<script type=text/tiscript>
class Foo
{
function attached() { this.insert("foo"); }
}
class Bar
{
function onKey(evt)
{
switch(evt.type)
{
case Event.KEY_CHAR | Event.HANDLED:
{
evt.target.style#prototype = "Foo";
}
}
}
function addBlock(parent = null)
{
this.$append(<div .block></div>);
var block = this.last;
block.state.focus = true;
}
}
self#add.onClick = function()
{
var el = self#body;
el.addBlock();
}
</script>
<body #body>
<button #add>Add</button>
</body>
</html> |