From a0b08f00d8be304207cfebabd62de88d0d135559 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Sat, 9 Dec 2023 19:47:37 +0800 Subject: [PATCH] add tk_quit_ex --- docs/changes.md | 1 + src/awtk_global.c | 11 ++++++++--- src/awtk_global.h | 13 +++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/changes.md b/docs/changes.md index 400465c92c..701382f3f2 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -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 来查询。 diff --git a/src/awtk_global.c b/src/awtk_global.c index a18811736c..82a2fae7dc 100644 --- a/src/awtk_global.c +++ b/src/awtk_global.c @@ -430,7 +430,7 @@ 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; @@ -438,11 +438,16 @@ static ret_t tk_quit_idle(const timer_info_t* timer) { 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; diff --git a/src/awtk_global.h b/src/awtk_global.h index 9aea8a2f6a..da71c63be2 100644 --- a/src/awtk_global.h +++ b/src/awtk_global.h @@ -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坐标。