• Administrator
  •  
    Support Ukraine
    If you experience any problems with the forum (it is not visible, there is no way to post messages, or some functionality does not work), please let us know. If you have problems with registration or you did not receive confirmation letter, let us know and we will activate your account manually.
    If you get an "The submitted form was invalid. Try submitting again" error, delete cookies, then try again.
     

How to change watch hand from javascript ?

Topics related to the creation, development, and designing of the watch faces.

Moderators: asoo, Watchmens

Forum rules
When adding a new topic, use the template: Topic title [device name]
For example: How to create watch face [Falcon]
All communication in this branch should only be in English.
Post Reply
zankezaa
Posts: 8
Joined: 10 Mar 2025, 12:02
Location: Indonesia
Contact:

How to change watch hand from javascript ?

Post by zankezaa »

Hi, i'll change my watch hand from javascript, i have try a someone script, but it not works on me.
Is there any a solution to solve this?

There my code :

Code: Select all

		
		//change watch hand
		let handnumber_1 = 1;
		let total_hand = 7; 

		function click_hand() {
			handnumber_1++;

			// kalau sudah melebihi jumlah total, balik lagi ke awal
			if (handnumber_1 > total_hand) {
				handnumber_1 = 1;
			}

			switch (handnumber_1) {
				case 1:
					UpdateHandOne();
					hmUI.showToast({ text: 'Style One' });
					break;
				case 2:
					UpdateHandTwo();
					hmUI.showToast({ text: 'Style Two' });
					break;
				case 3:
					UpdateHandThree();
					hmUI.showToast({ text: 'Style Three' });
					break;
				case 4:
					UpdateHandFour();
					hmUI.showToast({ text: 'Style Four' });
					break;
				case 5:
					UpdateHandFive();
					hmUI.showToast({ text: 'Style Five' });
					break;
				case 6:
					UpdateHandSix();
					hmUI.showToast({ text: 'Style Six' });
					break;
				case 7:
					UpdateHandSeven();
					hmUI.showToast({ text: 'Style Seven' });
					break;
			}
		}

		function UpdateHandOne() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H1.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M1.png");
		}

		function UpdateHandTwo() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H2.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M2.png");
		}

		function UpdateHandThree() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H3.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M3.png");
		}

		function UpdateHandFour() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H4.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M4.png");
		}
		function UpdateHandFive() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H5.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M5.png");
		}
		function UpdateHandSix() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H6.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M6.png");
		}
		function UpdateHandSeven() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H7.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M7.png");
		}
		
Are the code is correct?
User avatar
asoo
Posts: 2109
Joined: 03 Jan 2019, 01:48
Location: ͼͽ Thailand ͼͽ
Has thanked: 404 times
Been thanked: 2022 times

Post by asoo »

zankezaa wrote: 08 Nov 2025, 16:07
Hi, i'll change my watch hand from javascript, i have try a someone script, but it not works on me.
Is there any a solution to solve this?

There my code :

Code: Select all

		
		//change watch hand
		let handnumber_1 = 1;
		let total_hand = 7; 

		function click_hand() {
			handnumber_1++;

			// kalau sudah melebihi jumlah total, balik lagi ke awal
			if (handnumber_1 > total_hand) {
				handnumber_1 = 1;
			}

			switch (handnumber_1) {
				case 1:
					UpdateHandOne();
					hmUI.showToast({ text: 'Style One' });
					break;
				case 2:
					UpdateHandTwo();
					hmUI.showToast({ text: 'Style Two' });
					break;
				case 3:
					UpdateHandThree();
					hmUI.showToast({ text: 'Style Three' });
					break;
				case 4:
					UpdateHandFour();
					hmUI.showToast({ text: 'Style Four' });
					break;
				case 5:
					UpdateHandFive();
					hmUI.showToast({ text: 'Style Five' });
					break;
				case 6:
					UpdateHandSix();
					hmUI.showToast({ text: 'Style Six' });
					break;
				case 7:
					UpdateHandSeven();
					hmUI.showToast({ text: 'Style Seven' });
					break;
			}
		}

		function UpdateHandOne() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H1.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M1.png");
		}

		function UpdateHandTwo() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H2.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M2.png");
		}

		function UpdateHandThree() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H3.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M3.png");
		}

		function UpdateHandFour() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H4.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M4.png");
		}
		function UpdateHandFive() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H5.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M5.png");
		}
		function UpdateHandSix() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H6.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M6.png");
		}
		function UpdateHandSeven() {
            normal_analog_clock_time_pointer_hour_img.setProperty(hmUI.prop.SRC, "Hand_H7.png");
            normal_analog_clock_time_pointer_minute_img.setProperty(hmUI.prop.SRC, "Hand_M7.png");
		}
		
Are the code is correct?

Since you didn't submit the entire project, I can only speculate.
From the code you attached, it looks like you created the widget name yourself. If you were to use Sasha's editor, the "normal analog" widget name would likely be "normal_analog_clock_time_pointer_hour."
But I saw that you wrote in the script:
"normal_analog_clock_time_pointer_hour_img."
I think this is not correct, as this widget shouldn't exist, so you can't change it. And if you use the "normal_analog_clock_time_pointer_hour" widget to display the clock hands, you'll see that it doesn't have an SRC, so it can't be change image with SRC
If you want to change elements in this widget, you must use
.setProperty(hmUI.prop.MORE, to do this.

For example,

Code: Select all

normal_analog_clock_time_pointer_hour.setProperty(hmUI.prop.MORE, {
hour_path: 'Hand_H2.png',
hour_centerX: 233,
hour_centerY: 233,
hour_posX: 24,
hour_posY: 233,
hour_cover_path: 'HAND_CAP.png',
hour_cover_x: 224,
hour_cover_y: 224,
show_level: hmUI.show_level.ONLY_NORMAL,
});
When using MORE to change widget elements, it is recommended to write every line. Some widgets may not be able to change elements if they are not written in every line.

As mentioned, you didn't attach the entire project, so I can't verify whether my suggestions address your problem.
I can only speculate.
ͼͽ To request please use the interrelated forum in action ͼͽ
Please do not PM to me for requests ported watchface.
zankezaa
Posts: 8
Joined: 10 Mar 2025, 12:02
Location: Indonesia
Contact:

Post by zankezaa »

Is it possible to not attach a project, like having to attach a zip file of my watchface?

Thanks for the suggestions, i'll try your suggestions.
User avatar
asoo
Posts: 2109
Joined: 03 Jan 2019, 01:48
Location: ͼͽ Thailand ͼͽ
Has thanked: 404 times
Been thanked: 2022 times

Post by asoo »

zankezaa wrote: 08 Nov 2025, 17:03
Is it possible to not attach a project, like having to attach a zip file of my watchface?

Thanks for the suggestions, i'll try your suggestions.

You can also attach a zip file of the watchface, it will help too. But without any attaching the file, it would be difficult to answer the question directly.
Or if you want to replace the analog hands with " SRC ", I recommend switching to use widget "analog pro". The widget's name would be
"normal_analog_clock_pro_hour_pointer_img".
analog pro uses SRC, so you can change the visual elements with the command:

Code: Select all

normal_analog_clock_pro_hour_pointer_img.setProperty(hmUI.prop.SRC, "Hand_H1.png");
ͼͽ To request please use the interrelated forum in action ͼͽ
Please do not PM to me for requests ported watchface.
zankezaa
Posts: 8
Joined: 10 Mar 2025, 12:02
Location: Indonesia
Contact:

Post by zankezaa »

Thanks, its work using the Analog time pro. :D

And what widget are supporrted in ZeppOS?
Can you provide examples of widget in ZeppOS in script form?
I apologize in advance, because i am beginner in this watchface editor
User avatar
asoo
Posts: 2109
Joined: 03 Jan 2019, 01:48
Location: ͼͽ Thailand ͼͽ
Has thanked: 404 times
Been thanked: 2022 times

Post by asoo »

zankezaa wrote: 09 Nov 2025, 06:01
Thanks, its work using the Analog time pro. :D

And what widget are supporrted in ZeppOS?
Can you provide examples of widget in ZeppOS in script form?
I apologize in advance, because i am beginner in this watchface editor
All standard widgets are already available in Sasha's editor. The program includes all standard widgets. If you need a widget script, just enable the widget and pack it. You will get the script in index.js and you can use it as you wish.
ͼͽ To request please use the interrelated forum in action ͼͽ
Please do not PM to me for requests ported watchface.
zankezaa
Posts: 8
Joined: 10 Mar 2025, 12:02
Location: Indonesia
Contact:

Post by zankezaa »

Okay, thankyou very much asoo
Post Reply

Return to “Watchfaces discussion”

Who is online

Users browsing this forum: No registered users and 1 guest