Skip to content

Commit

Permalink
add tk_quit_ex
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Dec 9, 2023
1 parent b30756c commit a0b08f0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 增加函数 date\_time\_parse\_date/date\_time\_parse\_time/date\_time\_parse\_date\_time
* 完善 fscript ulen。
* edit 增加了 validator 属性,支持使用fscript校验输入数据是否合法。
* 增加函数tk\_quit\_ex

2023/12/07
* csv file object 支持通过 MVVM 来查询。
Expand Down
11 changes: 8 additions & 3 deletions src/awtk_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,24 @@ ret_t tk_run() {
return main_loop_run(main_loop());
}

static ret_t tk_quit_idle(const timer_info_t* timer) {
static ret_t tk_quit_in_timer(const timer_info_t* timer) {
main_loop_t* loop = main_loop();

loop->app_quited = TRUE;

return main_loop_quit(loop);
}

ret_t tk_quit() {
timer_add(tk_quit_idle, NULL, 0);
ret_t tk_quit_ex(uint32_t delay_ms) {
timer_add(tk_quit_in_timer, NULL, delay_ms);

return RET_OK;
}

ret_t tk_quit() {
return tk_quit_ex(0);
}

ret_t tk_set_lcd_orientation(lcd_orientation_t orientation) {
main_loop_t* loop = main_loop();
lcd_orientation_t old_orientation;
Expand Down
13 changes: 13 additions & 0 deletions src/awtk_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ ret_t tk_run(void);
*/
ret_t tk_quit(void);


/**
* @method tk_quit_ex
* 退出TK事件主循环。
* @alias global_quit_ex
* @annotation ["static", "scriptable"]
*
* @param {uint32_t} delay_ms 延迟退出的时间。
*
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
*/
ret_t tk_quit_ex(uint32_t delay_ms);

/**
* @method tk_get_pointer_x
* 获取全局指针的X坐标。
Expand Down

0 comments on commit a0b08f0

Please sign in to comment.