Skip to content

Commit 4dd35e0

Browse files
committed
Fix width of event navigator buttons. Prevent right-click from activating button auto-repeat.
1 parent 7f96ec6 commit 4dd35e0

7 files changed

Lines changed: 20 additions & 16 deletions

File tree

src/app/svc/svc-calendar-view/svc-calendar-view-options.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
<div class="inc-dec-pair">
44
<button pButton type="button" icon="fas fa-chevron-left" (click)="changeMonth(-1)"
55
(touchstart)="onTouchStart($event, -1)" (touchend)="stopClickTimer()"
6-
(mousedown)="onMouseDown(-1)" (mouseup)="stopClickTimer()" (mouseleave)="stopClickTimer()"></button>
6+
(mousedown)="onMouseDown(-1, $event)" (mouseup)="stopClickTimer()" (mouseleave)="stopClickTimer()"></button>
77
<span>Month</span>
88
<button pButton type="button" icon="fas fa-chevron-right" (click)="changeMonth(1)"
99
(touchstart)="onTouchStart($event, 1)" (touchend)="stopClickTimer()"
10-
(mousedown)="onMouseDown(1)" (mouseup)="stopClickTimer()" (mouseleave)="stopClickTimer()"></button>
10+
(mousedown)="onMouseDown(1, $event)" (mouseup)="stopClickTimer()" (mouseleave)="stopClickTimer()"></button>
1111
</div>
1212
<div class="inc-dec-pair">
1313
<button pButton type="button" icon="fas fa-chevron-left" (click)="changeMonth(-12)"
1414
(touchstart)="onTouchStart($event, -12)" (touchend)="stopClickTimer()"
15-
(mousedown)="onMouseDown(-12)" (mouseup)="stopClickTimer()" (mouseleave)="stopClickTimer()"></button>
15+
(mousedown)="onMouseDown(-12, $event)" (mouseup)="stopClickTimer()" (mouseleave)="stopClickTimer()"></button>
1616
<span>Year</span>
1717
<button pButton type="button" icon="fas fa-chevron-right" (click)="changeMonth(12)"
1818
(touchstart)="onTouchStart($event, 12)" (touchend)="stopClickTimer()"
19-
(mousedown)="onMouseDown(12)" (mouseup)="stopClickTimer()" (mouseleave)="stopClickTimer()"></button>
19+
(mousedown)="onMouseDown(12, $event)" (mouseup)="stopClickTimer()" (mouseleave)="stopClickTimer()"></button>
2020
</div>
2121
</div>
2222
<hr>

src/app/svc/svc-calendar-view/svc-calendar-view-options.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright © 2017 Kerry Shetline, kerry@shetline.com.
2+
Copyright © 2017-2019 Kerry Shetline, kerry@shetline.com.
33
44
This code is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -148,8 +148,8 @@ export class SvcCalendarViewOptionsComponent implements AfterViewInit, OnDestroy
148148
this.onMouseDown(delta);
149149
}
150150

151-
onMouseDown(delta: number): void {
152-
if (!this.clickTimer) {
151+
onMouseDown(delta: number, event?: MouseEvent): void {
152+
if (!this.clickTimer && (!event || event.button === 0)) {
153153
this.clickTimer = timer(CLICK_REPEAT_DELAY, CLICK_REPEAT_RATE).subscribe(() => {
154154
this.changeMonth(delta);
155155
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div class="flex-container" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="4px">
22
<button pButton type="button" icon="fas fa-chevron-left" [disabled]="disabled || !eventFinderReady"
33
(touchstart)="onTouchStart($event, true)" (touchend)="onTouchEnd($event)"
4-
(mousedown)="onMouseDown(true)" (mouseup)="onMouseUp()" (mouseleave)="stopClickTimer()"></button>
4+
(mousedown)="onMouseDown(true, $event)" (mouseup)="onMouseUp()" (mouseleave)="stopClickTimer()"></button>
55
<ks-dropdown scrollHeight="400px"
66
[options]="events" [(ngModel)]="selectedEvent" [disabled]="disabled || !eventFinderReady"></ks-dropdown>
77
<ks-dropdown scrollHeight="250px"
88
[options]="planets" [(ngModel)]="selectedPlanet" [disabled]="disabled || noPlanets || !eventFinderReady"></ks-dropdown>
99
<button pButton type="button" icon="fas fa-chevron-right" [disabled]="disabled || !eventFinderReady"
1010
(touchstart)="onTouchStart($event, false)" (touchend)="onTouchEnd($event)"
11-
(mousedown)="onMouseDown(false)" (mouseup)="onMouseUp()" (mouseleave)="stopClickTimer()"></button>
11+
(mousedown)="onMouseDown(false, $event)" (mouseup)="onMouseUp()" (mouseleave)="stopClickTimer()"></button>
1212
</div>
1313
<p-growl [value]="messages" [life]="6000"></p-growl>

src/app/svc/svc-event-navigator/svc-event-navigator.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright © 2017-2018 Kerry Shetline, kerry@shetline.com.
2+
Copyright © 2017-2019 Kerry Shetline, kerry@shetline.com.
33
44
This code is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -192,8 +192,8 @@ export class SvcEventNavigatorComponent implements AfterViewInit, OnDestroy {
192192
this.onMouseDown(goBack);
193193
}
194194

195-
onMouseDown(goBack: boolean): void {
196-
if (!this.clickTimer) {
195+
onMouseDown(goBack: boolean, event?: MouseEvent): void {
196+
if (!this.clickTimer && (!event || event.button === 0)) {
197197
this.lastGoBack = goBack;
198198

199199
this.clickTimer = timer(CLICK_REPEAT_DELAY, CLICK_REPEAT_RATE).subscribe(() => {

src/app/widgets/ks-calendar/ks-calendar.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright © 2017 Kerry Shetline, kerry@shetline.com
2+
Copyright © 2017-2019 Kerry Shetline, kerry@shetline.com
33
44
MIT license: https://opensource.org/licenses/MIT
55
@@ -230,7 +230,7 @@ export class KsCalendarComponent implements ControlValueAccessor, OnDestroy {
230230
}
231231

232232
onMouseDown(event: MouseEvent, delta: number): void {
233-
if (!this.timerSubscription) {
233+
if (!this.timerSubscription && (!event || event.button === 0)) {
234234
this.pendingEvent = event;
235235
this.pendingDelta = delta;
236236

src/app/widgets/ks-sequence-editor/ks-sequence-editor.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright © 2017-2018 Kerry Shetline, kerry@shetline.com
2+
Copyright © 2017-2019 Kerry Shetline, kerry@shetline.com
33
44
MIT license: https://opensource.org/licenses/MIT
55
@@ -447,7 +447,7 @@ export class KsSequenceEditorComponent implements AfterViewInit, OnInit, OnDestr
447447
}
448448

449449
onMouseDown(event: MouseEvent): void {
450-
if (this.disabled || this.viewOnly)
450+
if (this.disabled || this.viewOnly || event.button !== 0)
451451
return;
452452

453453
this.startSelectionAction(this.getSelectionForEvent(event));

src/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ body {
7171
.ui-chkbox, .ui-radiobutton { // Prevent checkbox/radio button layout from changing as buttons are checked/unchecked.
7272
min-height: 14px;
7373
}
74+
75+
button.ui-button-icon-only {
76+
min-width: 2em;
77+
}

0 commit comments

Comments
 (0)