Skip to content

Commit 4970922

Browse files
committed
Mouse handling: Improvements for cursor style.
Reset lowestPropagatedBoundSection variable on mouse move event. Because properties are not reset after mouse move. Lingering lowestPropagatedBoundSection property value causes trouble. ScrollSection: Set the cursor style if mouse is over a scrollbar. And also prevent the event propagation so MouseControl class doesn't get the event. When mouse is over tiles again, MouseControl class should handle the cursor style. Mouse control: SetCursorType function checks if the text cursor is visible or not. Make the check clearer because we need one more condition there. If we check only the existence of the class, we won't have checked the visibility of the text cursor. Signed-off-by: Gökay Şatır <[email protected]> Change-Id: I76cca4926d26bd4931ec729aceaad4aaf92c90c2
1 parent 31c4756 commit 4970922

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

browser/src/canvas/CanvasSectionContainer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,8 @@ class CanvasSectionContainer {
796796
break; // Stop propagation.
797797
}
798798
}
799+
800+
this.lowestPropagatedBoundSection = null; // onMouseMove event doesn't clear the mouse positions, so we need to clear the property here.
799801
}
800802

801803
private propagateOnMouseDown(section: CanvasSectionObject, position: Array<number>, e: MouseEvent) {

browser/src/canvas/sections/MouseControl.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ class MouseControl extends CanvasSectionObject {
130130
private setCursorType() {
131131
// If we have blinking cursor visible
132132
// we need to change cursor from default style
133-
if (app.map._docLayer._cursorMarker)
134-
app.map._docLayer._cursorMarker.setMouseCursor();
133+
if (app.file.textCursor.visible) this.context.canvas.style.cursor = 'text';
135134
else if (app.map._docLayer._docType === 'spreadsheet') {
136135
const textCursor =
137136
app.file.textCursor.visible &&
@@ -156,6 +155,8 @@ class MouseControl extends CanvasSectionObject {
156155
this.context.canvas.classList.add('spreadsheet-cursor');
157156
}
158157
}
158+
} else if (app.map._docLayer._docType === 'presentation') {
159+
this.context.canvas.style.cursor = '';
159160
}
160161
}
161162

browser/src/canvas/sections/ScrollSection.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ export class ScrollSection extends CanvasSectionObject {
491491
this.containerObject.requestReDraw();
492492
}
493493

494+
private setCursorForScrollBar(): void {
495+
this.context.canvas.style.cursor = 'pointer';
496+
if (this.context.canvas.classList.contains('spreadsheet-cursor'))
497+
this.context.canvas.classList.remove('spreadsheet-cursor');
498+
}
499+
494500
private isMouseOnScrollBar (point: cool.SimplePoint): void {
495501
const scrollProps: ScrollProperties = (app.activeDocument as DocumentBase).activeView.scrollProperties;
496502
const documentAnchor: CanvasSectionObject = app.sectionContainer.getSectionWithName(app.CSections.Tiles.name);
@@ -523,8 +529,9 @@ export class ScrollSection extends CanvasSectionObject {
523529
}
524530
else this.hideVerticalScrollBar();
525531

526-
if (this.sectionProperties.mouseIsOnHorizontalScrollBar || this.sectionProperties.mouseIsOnVerticalScrollBar)
527-
this.context.canvas.style.cursor = 'pointer';
532+
if (this.sectionProperties.mouseIsOnHorizontalScrollBar || this.sectionProperties.mouseIsOnVerticalScrollBar) {
533+
this.setCursorForScrollBar();
534+
}
528535
}
529536

530537
public onMouseLeave (): void {
@@ -643,8 +650,7 @@ export class ScrollSection extends CanvasSectionObject {
643650

644651
this.sectionProperties.previousDragDistance[1] = dragDistance[1];
645652

646-
e.stopPropagation(); // Don't propagate to map.
647-
this.stopPropagating(); // Don't propagate to bound sections.
653+
this.stopPropagating(); // Don't propagate to other sections.
648654
}
649655
else if (this.sectionProperties.clickScrollHorizontal && this.containerObject.isDraggingSomething()) {
650656
if (!this.sectionProperties.previousDragDistance) {
@@ -660,11 +666,12 @@ export class ScrollSection extends CanvasSectionObject {
660666
this.scrollHorizontalWithOffset(actualDistance);
661667

662668
this.sectionProperties.previousDragDistance[0] = dragDistance[0];
663-
e.stopPropagation(); // Don't propagate to map.
664-
this.stopPropagating(); // Don't propagate to bound sections.
669+
this.stopPropagating(); // Don't propagate to other sections.
665670
}
666671
else {
667672
this.isMouseOnScrollBar(position);
673+
if (this.sectionProperties.mouseIsOnVerticalScrollBar || this.sectionProperties.mouseIsOnHorizontalScrollBar)
674+
this.stopPropagating(); // Don't propagate to other sections.
668675
}
669676
}
670677

0 commit comments

Comments
 (0)