语言

Menu
Sites
Language
tizenhwkey listener on a watchface

Hello!

I've developed a watchface that includes a "settings" page where the watch wearer can change settings of the watchface like background colors, Celsius vs. Fahrenheit for the temperature, etc.  This "page" isn't really a page at all but rather another background stacked on top of the watch face using z-index.  I'd like to be able to bind some code to the gear's back button.  Even though the config.xml settings have HW Key Event enabled, the listener for the tizenhwkey event is never called when pressing the back button.  Below is my javascript code.  I'm running tizen 2.3.1. 

Is it possible to bind code to a tizehwkey event in a watchface?  Is there a better way to implement pages in a watchface?

    window.addEventListener('tizenhwkey', function(ev) {
        writeLog("key pressed!");
        });

I should mention, when I run my watch face using Tizen Studio 2.3's Tizen Web Simulator Application, the code works and, after pressing the "Back" button on the simulator, my log shows "key pressed!" as expected.  But when running on the emulator or my Gear S2 Classic, pressing the back button doesn't seem to work on this watch face.  I have similar code in a widget (not a watch face) and the code works fine there, so it seems to be isolated to watchfaces.

 

编辑者为: Alan Buch 09 4月, 2018
查看选择的答案

响应

1 回复
Mark as answer
Armaan-Ul- Islam

In Gear or Tizen Wearable Emulator a "Watchface" plays the role of 'Home Screen'.

 

A 'home screen app' can't have eventListeners for Hardware keys as the keys have different functions/works to do in that state. (For example: Home key (the lower button) opens the app drawer ). So, A developer/Watchface-designer can't add tizenhwkey eventListeners for Watchface app.