From cc6fc80bee3e186c090a1f4e18ec2849c58d03c5 Mon Sep 17 00:00:00 2001 From: Inez Korczynski Date: Sat, 5 Nov 2011 00:59:20 +0000 Subject: [PATCH] Support for deleting text with backspace and delete --- modules/es/views/es.SurfaceView.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/es/views/es.SurfaceView.js b/modules/es/views/es.SurfaceView.js index 855dd5c5ea..be4b7cb6fd 100644 --- a/modules/es/views/es.SurfaceView.js +++ b/modules/es/views/es.SurfaceView.js @@ -195,8 +195,14 @@ es.SurfaceView.prototype.onKeyDown = function( e ) { this.moveCursor( 'down' ); break; case 8: // Backspace + var transaction = this.documentView.model.prepareRemoval( new es.Range( this.selection.to, this.selection.to - 1 ) ); + this.documentView.model.commit ( transaction ); + this.selection.from = this.selection.to -= 1; + this.showCursor(); break; case 46: // Delete + var transaction = this.documentView.model.prepareRemoval( new es.Range( this.selection.to, this.selection.to + 1 ) ); + this.documentView.model.commit ( transaction ); break; default: // Insert content (maybe) if ( this.keyboard.keydownTimeout ) { @@ -217,7 +223,7 @@ es.SurfaceView.prototype.insertFromInput = function() { if ( val.length > 0 ) { var transaction = this.documentView.model.prepareInsertion( this.selection.to, val.split('') ); this.documentView.model.commit ( transaction ); - this.selection.to += val.length; + this.selection.from = this.selection.to += val.length; this.showCursor(); } };