有人可以解释在 Pebble C Watchface 教程中找到的部分代码吗?
Can someone explain part of this code found in the Pebble C Watchface tutorial?
我正在查看此处的 Pebble C 表盘教程 https://developer.getpebble.com/tutorials/watchface-tutorial/part1
有问题的部分代码在这里:
static void init() {
// Create main Window element and assign to pointer
s_main_window = window_create();
// Set handlers to manage the elements inside the Window
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload
});
// Show the Window on the watch, with animated=true
window_stack_push(s_main_window, true);
}
window_set_window_handlers是函数声明和调用吗? C 中 .load 和 .unload shorthand 表示法的术语是什么?
如果有人可以解释该代码片段,将不胜感激,谢谢。
叫做Designated Initializers. The struct WindowHandlers
is created and initialized inline before being passed to the function call of window_set_window_handlers
。
我正在查看此处的 Pebble C 表盘教程 https://developer.getpebble.com/tutorials/watchface-tutorial/part1
有问题的部分代码在这里:
static void init() {
// Create main Window element and assign to pointer
s_main_window = window_create();
// Set handlers to manage the elements inside the Window
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload
});
// Show the Window on the watch, with animated=true
window_stack_push(s_main_window, true);
}
window_set_window_handlers是函数声明和调用吗? C 中 .load 和 .unload shorthand 表示法的术语是什么?
如果有人可以解释该代码片段,将不胜感激,谢谢。
叫做Designated Initializers. The struct WindowHandlers
is created and initialized inline before being passed to the function call of window_set_window_handlers
。