MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / selectDevice

Method selectDevice

tools/mcsim/main.js:320–354  ·  view source on GitHub ↗
(application, index)

Source from the content-addressed store, hash-verified

318 }
319 }
320 selectDevice(application, index) {
321 application.distribute("onDeviceUnselected");
322
323 this.deviceIndex = index;
324 let device = (index < 0) ? noDevice : this.devices[index];
325 let rotation = this.deviceRotation;
326 let Templates = device.DeviceTemplates;
327 let Template = device.DeviceTemplates;
328 if (Templates) {
329 if (rotation in Templates)
330 Template = Templates[rotation];
331 else
332 Template = Templates[0];
333 }
334 else
335 Template = device.DeviceTemplate;
336
337 let screenContainer = new Template(device);
338 let container = this.DEVICE;
339 container.replace(container.first, screenContainer);
340
341 if (this.CONTROLS) {
342 let controlsColumn = new device.ControlsTemplate(device);
343 let scroller = this.CONTROLS.first;
344 scroller.replace(scroller.first, controlsColumn);
345 }
346
347// let path = device.applicationPath;
348// if (path && system.fileExists(path))
349// this.libraryPath = path;
350// else
351// this.libraryPath = "";
352
353 application.distribute("onDeviceSelected", device);
354 }
355
356/* EVENTS */
357 onAbort(application, status, reason) {

Callers 6

onAppearanceChangedMethod · 0.95
reloadDevicesMethod · 0.95
onRotateMethod · 0.95
onSelectDeviceMethod · 0.95
doOpenFileCallbackMethod · 0.95
doSelectRotationMethod · 0.95

Calls 2

distributeMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected