Esempio n. 1
0
rt_bool_t player_workbench_event_handler(rtgui_widget_t *widget, rtgui_event_t *event)
{
    if (event->type == RTGUI_EVENT_KBD)
    {
        struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*)event;
        if (((ekbd->type == RTGUI_KEYUP) && ekbd->key == RTGUIK_HOME)
                && !RTGUI_WORKBENCH_IS_MODAL_MODE(workbench))
        {
            /* active home view */
            if (workbench->current_view != home_view)
            {
                rtgui_view_show(home_view, RT_FALSE);
                return RT_TRUE;
            }
        }
    }
	else if (event->type == RTGUI_EVENT_COMMAND)
	{
        struct rtgui_event_command* ecmd = (struct rtgui_event_command*)event;

		if ((ecmd->command_id == PLAYER_REQUEST_FUNCTION_VIEW) &&
			!RTGUI_WORKBENCH_IS_MODAL_MODE(workbench))
		{
			rtgui_view_show(RTGUI_VIEW(function_view), RT_FALSE);
			return RT_TRUE;
		}
		else
		{
			/* let default workbench event handler to handle it */
			return rtgui_workbench_event_handler(widget, event);
		}
	}

    return rtgui_workbench_event_handler(widget, event);
}
Esempio n. 2
0
static rt_bool_t demo_workbench_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
{
	/* 我们目前只对按键事件感兴趣。如果当前workbench处于模式显示状态,忽略它  */
	if ((event->type == RTGUI_EVENT_KBD) && !RTGUI_WORKBENCH_IS_MODAL_MODE(RTGUI_WORKBENCH(widget)))
	{
		struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*)event;

		if (ekbd->type == RTGUI_KEYDOWN)
		{
			if (ekbd->key == RTGUIK_RIGHT)
			{
				demo_view_next(RT_NULL, RT_NULL);
				return RT_TRUE;
			}
			else if (ekbd->key == RTGUIK_LEFT)
			{
				demo_view_prev(RT_NULL, RT_NULL);
				return RT_TRUE;
			}
		}
	}

	/* 如果不是绘制事件,使用view原来的事件处理函数处理 */
	return rtgui_workbench_event_handler(widget, event);
}