comparison Applications/StoneWebViewer/WebApplication/app.js @ 2019:fe9999d6a636

handling of left, right, and space keys
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 03 Dec 2022 09:22:19 +0100
parents 7e45941acc1d
children 88673f50d7b9
comparison
equal deleted inserted replaced
2018:6099c7925202 2019:fe9999d6a636
348 if (args.detail.canvasId == that.canvasId) { 348 if (args.detail.canvasId == that.canvasId) {
349 that.windowingCenter = args.detail.windowingCenter; 349 that.windowingCenter = args.detail.windowingCenter;
350 that.windowingWidth = args.detail.windowingWidth; 350 that.windowingWidth = args.detail.windowingWidth;
351 } 351 }
352 }); 352 });
353
354 window.addEventListener('CineSwitch', function(args) {
355 if (that.active) {
356 that.CineSwitch();
357 }
358 });
353 }, 359 },
354 methods: { 360 methods: {
355 DragDrop: function(event) { 361 DragDrop: function(event) {
356 event.preventDefault(); 362 event.preventDefault();
357 363
370 IncrementFrame: function(isCircular) { 376 IncrementFrame: function(isCircular) {
371 return stone.IncrementFrame(this.canvasId, isCircular); 377 return stone.IncrementFrame(this.canvasId, isCircular);
372 }, 378 },
373 CinePlay: function() { 379 CinePlay: function() {
374 this.cineControls = true; 380 this.cineControls = true;
375 this.cineIncrement = 1; 381 this.cineIncrement = -1;
376 this.UpdateCine(); 382 this.UpdateCine();
377 }, 383 },
378 CinePause: function() { 384 CinePause: function() {
379 if (this.cineIncrement == 0) { 385 if (this.cineIncrement == 0) {
380 // Two clicks on the "pause" button will hide the playback control 386 // Two clicks on the "pause" button will hide the playback control
384 this.UpdateCine(); 390 this.UpdateCine();
385 } 391 }
386 }, 392 },
387 CineBackward: function() { 393 CineBackward: function() {
388 this.cineControls = true; 394 this.cineControls = true;
389 this.cineIncrement = -1; 395 this.cineIncrement = 1;
390 this.UpdateCine(); 396 this.UpdateCine();
397 },
398 CineSwitch: function() {
399 if (this.cineIncrement != 0) {
400 this.CinePause();
401 } else {
402 this.CinePlay();
403 }
391 }, 404 },
392 UpdateCine: function() { 405 UpdateCine: function() {
393 // Cancel the previous cine loop, if any 406 // Cancel the previous cine loop, if any
394 if (this.cineTimeoutId !== null) { 407 if (this.cineTimeoutId !== null) {
395 clearTimeout(this.cineTimeoutId); 408 clearTimeout(this.cineTimeoutId);
749 this.viewport4Content = { 762 this.viewport4Content = {
750 series: series, 763 series: series,
751 virtualSeriesId: info.virtualSeriesId 764 virtualSeriesId: info.virtualSeriesId
752 }; 765 };
753 } 766 }
767
768 // Give the focus to this viewport (new in Stone Web viewer 2.5)
769 this.activeViewport = viewportIndex;
754 }, 770 },
755 771
756 ClickSeries: function(seriesIndex) { 772 ClickSeries: function(seriesIndex) {
757 this.SetViewportSeries(this.activeViewport, { 773 this.SetViewportSeries(this.activeViewport, {
758 seriesIndex: seriesIndex 774 seriesIndex: seriesIndex
1239 stone.AddTextAnnotation(args.detail.canvasId, label, 1255 stone.AddTextAnnotation(args.detail.canvasId, label,
1240 args.detail.pointedX, args.detail.pointedY, 1256 args.detail.pointedX, args.detail.pointedY,
1241 args.detail.labelX, args.detail.labelY); 1257 args.detail.labelX, args.detail.labelY);
1242 } 1258 }
1243 }); 1259 });
1260
1261 window.addEventListener('keydown', function(event) {
1262 var canvas = that.GetActiveCanvas();
1263 if (canvas != '') {
1264 switch (event.key) {
1265 case 'Left':
1266 case 'ArrowLeft':
1267 stone.DecrementFrame(canvas, false);
1268 event.preventDefault();
1269 break;
1270
1271 case 'Right':
1272 case 'ArrowRight':
1273 stone.IncrementFrame(canvas, false);
1274 event.preventDefault();
1275 break;
1276
1277 case 'Up':
1278 case 'ArrowUp':
1279 break;
1280
1281 case 'Down':
1282 case 'ArrowDown':
1283 break;
1284
1285 case ' ':
1286 case 'Space':
1287 dispatchEvent(new CustomEvent('CineSwitch', { }));
1288 event.preventDefault();
1289 break;
1290
1291 default:
1292 break;
1293 }
1294 }
1295 });
1244 } 1296 }
1245 }); 1297 });
1246 1298
1247 1299
1248 1300