diff options
| author | Grissiom <[email protected]> | 2013-02-01 10:27:10 +0800 |
|---|---|---|
| committer | Grissiom <[email protected]> | 2013-02-01 10:27:10 +0800 |
| commit | f06c70feed0941b5bceedcecf89e9aa22034aca8 (patch) | |
| tree | 89fd3a989b4d88fc72b39eaad6567de3a3d23874 /components/rtgui/widgets/button.c | |
| parent | 4f02e67bef7eacee5102d7730356663d9c889e15 (diff) | |
sync with rtgui-0.6
Diffstat (limited to 'components/rtgui/widgets/button.c')
| -rw-r--r-- | components/rtgui/widgets/button.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/components/rtgui/widgets/button.c b/components/rtgui/widgets/button.c index ca15acb89a..ceca58f008 100644 --- a/components/rtgui/widgets/button.c +++ b/components/rtgui/widgets/button.c @@ -104,7 +104,8 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_object *object, struct rtgui_e break; case RTGUI_EVENT_MOUSE_BUTTON: - if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE; + if (RTGUI_WIDGET_IS_HIDE(widget)) + return RT_FALSE; { struct rtgui_event_mouse *emouse = (struct rtgui_event_mouse *)event; @@ -159,9 +160,6 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_object *object, struct rtgui_e /* need callback */ rt_bool_t need_cb = RT_FALSE; - win = RTGUI_WIN(RTGUI_WIDGET(btn)->toplevel); - win->last_mevent_widget = RTGUI_WIDGET(btn); - /* we need to decide whether the callback will be invoked * before the flag has changed. Moreover, we cannot invoke * it directly here, because the button might be destroyed @@ -174,14 +172,20 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_object *object, struct rtgui_e need_cb = RT_TRUE; } - /* it's a normal button */ + /* if the button will handle the mouse up event here, it + * should not be the last_mevent_widget. Take care that + * don't overwrite other widgets. */ + win = RTGUI_WIN(RTGUI_WIDGET(btn)->toplevel); if (emouse->button & RTGUI_MOUSE_BUTTON_DOWN) { btn->flag |= RTGUI_BUTTON_FLAG_PRESS; + win->last_mevent_widget = RTGUI_WIDGET(btn); } else { btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS; + if (win->last_mevent_widget == RTGUI_WIDGET(btn)) + win->last_mevent_widget = RT_NULL; } /* draw button */ |
