当前位置: 首页>>代码示例>>C++>>正文


C++ WindowInfo::char_callback方法代码示例

本文整理汇总了C++中WindowInfo::char_callback方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowInfo::char_callback方法的具体用法?C++ WindowInfo::char_callback怎么用?C++ WindowInfo::char_callback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WindowInfo的用法示例。


在下文中一共展示了WindowInfo::char_callback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: process_event

static int process_event(XEvent* event) {
    KeySym sym;

    WindowInfo* info = find_handle(event->xany.window);

    if (!info)
        return 1;

    if (event->type == ClientMessage) {
        if ((Atom)event->xclient.data.l[0] == s_wm_delete_window) {
            info->update = 0;
            mfb_close(info);

            return 0;
        }
    }

    switch (event->type) 
    {
        case KeyPress:
        {
            sym = XLookupKeysym(&event->xkey, 0);

			if (handle_special_keys(info, event, 1))
				break;

            if (info->key_callback)
                info->key_callback(info->rust_data, sym, 1);

            if (info->char_callback) {
				unsigned int t = keySym2Unicode(sym);
				if (t != -1)
					info->char_callback(info->rust_data, t);
            }

            break;
        }

        case KeyRelease:
        {
			if (handle_special_keys(info, event, 0))
				break;

            sym = XLookupKeysym(&event->xkey, 0);

            if (info->key_callback)
                info->key_callback(info->rust_data, sym, 0);
            break;
        }

        case ButtonPress:
        {
            if (!info->shared_data)
                break;

            if (event->xbutton.button == Button1)
                info->shared_data->state[0] = 1;
            else if (event->xbutton.button == Button2)
                info->shared_data->state[1] = 1;
            else if (event->xbutton.button == Button3)
                info->shared_data->state[2] = 1;
            else if (event->xbutton.button == Button4)
                info->shared_data->scroll_y = 10.0f;
            else if (event->xbutton.button == Button5)
                info->shared_data->scroll_y = -10.0f;
            else if (event->xbutton.button == Button6)
                info->shared_data->scroll_x = 10.0f;
            else if (event->xbutton.button == Button7)
                info->shared_data->scroll_y = -10.0f;

            break;
        }

        case ButtonRelease:
        {
            if (!info->shared_data)
                break;

            if (event->xbutton.button == Button1) 
                info->shared_data->state[0] = 0;
            else if (event->xbutton.button == Button2)
                info->shared_data->state[1] = 0;
            else if (event->xbutton.button == Button3)
                info->shared_data->state[2] = 0;

            break;
        }

        case ConfigureNotify:
        {
            info->width = event->xconfigure.width;
            info->height = event->xconfigure.height;
            break;
        }
    }

    return 1;
}
开发者ID:emoon,项目名称:rust_minifb,代码行数:98,代码来源:X11MiniFB.c


注:本文中的WindowInfo::char_callback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。