12-29-2020 18:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

12-29-2020 18:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Unlike my last question, I'm sure I'm not zoomed in or scrolled. Click events still work in my 4.2 watch faces. I mocked up a minimal example based on https://dev.fitbit.com/build/guides/user-interface/javascript/#click-event but it still won't recognize any click events (i.e. no log to console and any function I put in the event listener function doesn't run). Any help would be appreciated.
index.js
import document from "document";
let myRect = document.getElementById("myRect");
myRect.addEventListener("click", (evt) => {
console.log("click");
});
index.view
<svg fill="black">
<rect id="myRect" pointer-events="visible" />
</svg>
Answered! Go to the Best Answer.
Accepted Solutions
12-30-2020 12:19
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


12-30-2020 12:19
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
How odd; it works fine for me (Windows, no display scaling). I'm not aware of any relevant difference between SDK 4.2 and 5 in this regard.
Gondwana Software
12-29-2020 18:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


12-29-2020 18:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I haven't tested this, but try
<rect id="myRect" width="100%" height="100%" pointer-events="visible" />
Gondwana Software

12-30-2020 09:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

12-30-2020 09:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
It didn't work, unfortunately. Does anyone have a minimal working example of click events for SDK 5.0?

12-30-2020 11:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


12-30-2020 11:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
<rect id="touch" width="100%" height="100%" fill="white" opacity="0" pointer-events="visible" />
touchEl.onclick = onTouchClick;
function onTouchClick() {
};
Lots of ways to skin a cat, and some obvious stuff omitted.
Gondwana Software

12-30-2020 12:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

12-30-2020 12:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Still nothing. I think there is a problem with my simulator and not my code. I copied the SDK 5 demo app here https://github.com/Fitbit/sdk-app-demo/ and it won't work at all. I can turn the screen on and off using the simulated buttons but it doesn't recognize any click on the screen. Clicks on 4.2 clocks/apps still work, however.

12-30-2020 12:19
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


12-30-2020 12:19
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
How odd; it works fine for me (Windows, no display scaling). I'm not aware of any relevant difference between SDK 4.2 and 5 in this regard.
Gondwana Software
12-30-2020 12:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

12-30-2020 12:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Your scaling comment got me on the right track. I went into the application properties and changed the scaling settings on my display for the simulator. When my display is scaled at 150%, the simulator registers the click events. Thanks for helping me troubleshoot yet again!
12-30-2020 13:56
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


12-30-2020 13:56
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thanks! I'm glad you picked up on that. I threw in scaling because I know it has caused problems, but I couldn't see how it would depend on SDK version. Maybe it does!
Gondwana Software

12-30-2020 15:21
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

12-30-2020 15:21
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I suppose it has something to do with the resolution of the simulated display because it was only refusing to register events on the screen. That's what threw me off for so long; I assumed that it had to be a code problem because it worked in 4.2 and I could use the buttons in 5.0.

12-30-2020 15:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


12-30-2020 15:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Good theory! I assumed they were both native (1:1), but I never checked. I find that screenshots of the simulator are always 1:1 with the watch screen resolution; I don't know if that's significant.
Gondwana Software

