Skip to content

Commit 2f94106

Browse files
Merge pull request #37 from EclipseTrading/VC-6558-fire-selection-change-on-mouse-up
VC-6558 do not fire selection change on mouse drags
2 parents 61fabeb + 96a6855 commit 2f94106

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eclipsetrading/hypergrid",
3-
"version": "4.4.2",
3+
"version": "4.5.0",
44
"description": "Canvas-based high-performance grid",
55
"main": "dist/src/Hypergrid/index.js",
66
"typings": "dist/src/Hypergrid/index.d.ts",

src/Hypergrid/selection.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,15 @@ exports.mixin = {
142142
* @param {number} oy - origin y
143143
* @param {number} ex - extent x
144144
* @param {number} ex - extent y
145+
* @param {Boolean} [silent=false] - whether to trigger selection changed event
145146
*/
146-
select: function(ox, oy, ex, ey) {
147+
select: function(ox, oy, ex, ey, silent = false) {
147148
if (ox < 0 || oy < 0) {
148149
//we don't select negative area
149150
//also this means there is no origin mouse down for a selection rect
150151
return;
151152
}
152-
this.selectionModel.select(ox, oy, ex, ey);
153+
this.selectionModel.select(ox, oy, ex, ey, silent);
153154
},
154155

155156
/**

src/features/CellSelection.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ var CellSelection = Feature.extend('CellSelection', {
5252
handleMouseUp: function(grid, event) {
5353
if (this.dragging) {
5454
this.dragging = false;
55+
if(this.dragSelect){
56+
grid.selectionChanged(false);
57+
this.dragSelect = false
58+
}
5559
}
5660
if (this.next) {
5761
this.next.handleMouseUp(grid, event);
@@ -95,8 +99,10 @@ var CellSelection = Feature.extend('CellSelection', {
9599
if (this.dragging && grid.properties.cellSelection && !event.primitiveEvent.detail.isRightClick) {
96100
this.currentDrag = event.primitiveEvent.detail.mouse;
97101
this.lastDragCell = grid.newPoint(event.gridCell.x, event.dataCell.y);
102+
103+
this.dragSelect = true
98104
this.checkDragScroll(grid, this.currentDrag);
99-
this.handleMouseDragCellSelection(grid, this.lastDragCell, event.primitiveEvent.detail.keys);
105+
this.handleMouseDragCellSelection(grid, this.lastDragCell, event.primitiveEvent.detail.keys, true);
100106
} else if (this.next) {
101107
this.next.handleMouseDrag(grid, event);
102108
}
@@ -144,7 +150,7 @@ var CellSelection = Feature.extend('CellSelection', {
144150
* @param {Object} mouse - the event details
145151
* @param {Array} keys - array of the keys that are currently pressed down
146152
*/
147-
handleMouseDragCellSelection: function(grid, gridCell, keys) {
153+
handleMouseDragCellSelection: function(grid, gridCell, keys, silent) {
148154
var x = Math.max(0, gridCell.x),
149155
y = Math.max(0, gridCell.y),
150156
previousDragExtent = grid.getDragExtent(),
@@ -158,7 +164,7 @@ var CellSelection = Feature.extend('CellSelection', {
158164

159165
grid.clearMostRecentSelection();
160166

161-
grid.select(mouseDown.x, mouseDown.y, newX, newY);
167+
grid.select(mouseDown.x, mouseDown.y, newX, newY, silent);
162168
grid.setDragExtent(grid.newPoint(newX, newY));
163169

164170
grid.repaint();

0 commit comments

Comments
 (0)