Hi,
I have a class derived from WatchUi.View, that when is being shown gives the following error whenever I press the (physical) button on the clock (vívoactive 3):
(from CIQ_LOG.YML)
Error: Symbol Not Found Error
Details: "Could not find symbol 'KeyEvent'"
Time: 2022-07-20T14:17:47Z
Part-Number: XXX-XXXXX-00
Firmware-Version: '8.10'
Language-Code: por
ConnectIQ-Version: 4.1.4
Filename: -----
Appname: -----
Stack:
- pc: 0x30001d07
- pc: 0x30001fb0
In the simulator, I also can see the error:
Error: Symbol Not Found Error
Details: Could not find symbol 'KeyEvent'
Stack:
- handleEvent() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:1065 0x30002252
- handleEvent() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:1262 0x300024fd
The curious thing is that neither the class derived from the View nor the one from BehaviorDelegate has any reference to WatchUi.KeyEvent (in fact now they do, as I added it to try to see if I could overcome the problem by forcing the use of the "KeyEvent" symbol in those classes... with no success).
The stack trace seems to point to an internal API error.
Can anyone help?
Thank you
UPDATE
I found that the VM appears to be getting confused when the (user) namespace contains "WatchUi". Any class derived from WatchUi.View within a namespace or subnamespace with that token (eg XYZ.WatchUi, X.Y.Z.WatchUi or X.Y.Z.WatchUi.Sub) will produce the error when the physical button is clicked.
The following example works fine, but when we change the subnamespace from "WatchUi2" to "WatchUi" it will produce the error described above:
import Toybox.Lang; using Toybox.Application; using Toybox.WatchUi as Ui; using XYZ.WatchUi2 as XW; class XYZApp extends Application.AppBase { public function initialize() { AppBase.initialize(); } public function getInitialView() as Lang.Array<Ui.Views or Ui.InputDelegates>? { var result = [ new XW.EmptyWindowView(), new XW.EmptyWindowDelegate() ] as Lang.Array<Ui.View or Ui.InputDelegate>; return result; } }
import Toybox.Lang; using Toybox.Graphics as Gfx; using Toybox.WatchUi as Ui; module XYZ { module WatchUi2 { class EmptyWindowView extends Ui.View { function initialize() { View.initialize(); } // Load your resources here function onLayout(dc as Gfx.Dc) as Void { } // Called when this View is brought to the foreground. Restore the state of this View and prepare it to be shown. // This includes loading resources into memory. function onShow() as Void { } // Called when this View is removed from the screen. Save the state of this View here. This includes freeing resources from memory. function onHide() as Void { } // Update the view function onUpdate(dc as Gfx.Dc) as Void { View.onUpdate(dc); } } } }
import Toybox.Lang; using Toybox.WatchUi as Ui; module XYZ { module WatchUi2 { class EmptyWindowDelegate extends Ui.BehaviorDelegate { function initialize() { BehaviorDelegate.initialize(); } } } }