- selection can be extended by shift clicking

- clicking on the start of a selection clears it
This commit is contained in:
Fabian Jakobs 2010-10-05 12:17:31 +02:00
commit 602af86e94
2 changed files with 8 additions and 3 deletions

View file

@ -271,9 +271,13 @@ var Editor = function(renderer, doc) {
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
pos.row = Math.max(0, Math.min(pos.row, this.doc.getLength()-1));
this.moveCursorToPosition(pos);
if (!this.$clickSelection)
this.selection.setSelectionAnchor(pos.row, pos.column);
if (e.shiftKey)
this.selection.selectToPosition(pos)
else {
this.moveCursorToPosition(pos);
if (!this.$clickSelection)
this.selection.clearSelection(pos.row, pos.column);
}
this.renderer.scrollCursorIntoView();

View file

@ -363,6 +363,7 @@ var Selection = function(doc) {
this.moveCursorTo = function(row, column) {
var cursor = this.$clipPositionToDocument(row, column);
// only dispatch change if the cursor actually changed
if (cursor.row !== this.selectionLead.row || cursor.column !== this.selectionLead.column) {
this.selectionLead = cursor;
this.$dispatchEvent("changeCursor", { data: this.getCursor() });