Use return/enter only to create a new RichText component, not to insert it into the new RichText?

edited September 2013 in General
So basically I have a list of RichTexts and every time I hit return inside a RichText I have it so that a new RichText gets created below it and set focus to it, my problem though is that once it has been created and gotten a focus the return key press inserts a "< br >" into the new RichText, how can I make it so that the new RichText is empty or contains a value I want and not a < br >?

I'm thinking I can perhaps somehow stop the the keypress from returning a < br > and just return false?

jsFiddle: http://jsfiddle.net/vJdce/1/

Code:
enyo.kind({
	name: "App",
	kind: "FittableRows",
	fit: true,
	components:[
		{kind: "rwList"}
	]
});

enyo.kind({
	name: "rwList",
	changingLife: false,
	changingStep: false,
	itemKind: "rwListItem",
	components:[
		{tag: "ul", name: "goals"}
	],
	create: function() {
		this.inherited(arguments);
		var that = this;
		that.createNode(0);
	},
	createNode: function(order, value, focus) {
		if (this.$.goals.children[order] == undefined) {
			this.createComponent({tag:"li", container: this.$.goals});	
			this.createComponent({kind:this.itemKind, value: value, container: this.$.goals.children[order]});
		} else {
			var c = this.createComponent({tag:"li"});
			this.$.goals.addChild(c, order);
			this.createComponent({kind:this.itemKind, value: value, container: c});
		}

		for (var x = 0; x < this.$.goals.children.length; x++) {
			this.$.goals.children[x].children[0].order = x;
		}

		this.$.goals.render();
		this.$.goals.children[order].children[0].$.input.focus();
	}
});

enyo.kind({
	name: "rwListItem",
	components: [
		{name: "input",
		 kind: "enyo.RichText",
		 style:'display: block; border: 1px solid blue;',
		 onchange:"inputChanged", 
		 onkeydown:"keyDown",
		 oninput: "input",
		}
	],
	create: function() {
		this.inherited(arguments);
		if (this.value == undefined) this.value = "";
		this.$.input.setValue(this.value);
	},
	keyDown: function(inSender, inEvent) {
		if (inEvent.keyCode == 13) {
			this.owner.createNode(this.order+1);
    	}
    }
});

Comments

Sign In or Register to comment.