Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

click events not registering in the simulator (only for SDK 5.0)

ANSWERED

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>

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
9 REPLIES 9

I haven't tested this, but try

<rect id="myRect" width="100%" height="100%" pointer-events="visible" />
Peter McLennan
Gondwana Software
Best Answer
0 Votes

It didn't work, unfortunately. Does anyone have a minimal working example of click events for SDK 5.0?

Best Answer
0 Votes
<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.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

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.

Best Answer
0 Votes

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.

Peter McLennan
Gondwana Software
Best Answer

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!

Best Answer

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!

Peter McLennan
Gondwana Software
Best Answer
0 Votes

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.

Best Answer
0 Votes

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.

Peter McLennan
Gondwana Software
Best Answer
0 Votes