• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            08年05月20日

            Posted on 2008-05-20 16:34 RichardHe 閱讀(237) 評論(0)  編輯 收藏 引用
            CEGUI的事件監聽器又是如何實現的呢?
            對于控件,每種控件有自己的事件,如:EventKeyUp等;每個事件后面可以掛著N個事件的回調方法;
            event:function1,function2......
            對控件訂閱事件,如button->subscribeEvent(CEGUI::Windos::EventKeyUp,CEGUI:Event::Subscriber(&function,this));
            把事件EventKeyUp注冊到button中,并且在事件響應時回調函數fuction

            內部實現機制是怎么樣的呢?內部好像通過一個Map來查找到這個事件,但是又是如何響應到function的呢?哪位大哥指點下?

            原來是一步步調用.我們設置一個斷點在function,在DEBUG模式下"調用堆棧"
            virtual bool operator()(const EventArgs& args)
                {
                    return (d_object->*d_function)(args);
                }
            再根據多態性
              bool operator()(const EventArgs& args) const
                {
                    return (*d_functor_impl)(args);
                }
            在事件類中
            void Event::operator()(EventArgs& args)
            {
                SlotContainer::iterator iter(d_slots.begin());
                const SlotContainer::const_iterator end_iter(d_slots.end());

                // execute all subscribers, updating the 'handled' state as we go
                for (; iter != end_iter; ++iter)
                    args.handled |= (*iter->second->d_subscriber)(args);
            }
            事件設置:
            void EventSet::fireEvent_impl(const String& name, EventArgs& args)
            {
                // find event object
                Event* ev = getEventObject(name);

                // fire the event if present and set is not muted
                if ((ev != 0) && !d_muted)
                    (*ev)(args);
            }
            void EventSet::fireEvent(const String& name, EventArgs& args, const String& eventNamespace)
            {
                // handle global events
                GlobalEventSet::getSingleton().fireEvent(name, args, eventNamespace);
                // handle local event
                fireEvent_impl(name, args);
            }
            再到Window窗口中
            void Window::onMouseClicked(MouseEventArgs& e)
            {
                fireEvent(EventMouseClick, e, EventNamespace);
            }
            再到
            bool System::injectMouseButtonUp(MouseButton button)
            {
             ....
             while ((!ma.handled) && (dest_window != 0))
                    {
                        ma.window = dest_window;
                        dest_window->onMouseClicked(ma);
                        dest_window = getNextTargetWindow(dest_window);
                    }
             ....
            }
            最后在Windows 消息處理中
            LRESULT CALLBACK Win32AppHelper::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
            {
                switch(message)
                {
                    .....
                    case WM_LBUTTONUP:
                    CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
                    break;
                    .....
                }

            posts - 94, comments - 138, trackbacks - 0, articles - 94

            Copyright © RichardHe

            2021国产精品久久精品| av午夜福利一片免费看久久| 久久国产影院| 无码人妻久久一区二区三区蜜桃| 久久人人爽人人爽人人片AV东京热| 亚洲午夜久久久久久久久久 | 亚洲国产精品无码久久98| 国产精品99久久久精品无码| 久久久久女人精品毛片| 久久99精品国产麻豆不卡| 久久婷婷色综合一区二区 | 久久精品成人免费观看97| 国产毛片欧美毛片久久久| 精品国产婷婷久久久| 97热久久免费频精品99| 久久亚洲精品国产亚洲老地址 | 久久天天躁狠狠躁夜夜不卡| 久久精品无码专区免费东京热| 国产AⅤ精品一区二区三区久久| 久久香综合精品久久伊人| 久久久久国产日韩精品网站| 婷婷久久香蕉五月综合加勒比| 久久久91人妻无码精品蜜桃HD| 久久精品aⅴ无码中文字字幕重口| 久久免费99精品国产自在现线| 成人国内精品久久久久影院| 久久无码AV一区二区三区| 久久影院久久香蕉国产线看观看| 91久久精品国产91性色也| 漂亮人妻被黑人久久精品| 久久天天躁狠狠躁夜夜2020一 | 色偷偷偷久久伊人大杳蕉| 久久精品免费一区二区| 久久婷婷色香五月综合激情| 日韩va亚洲va欧美va久久| 武侠古典久久婷婷狼人伊人| 久久男人AV资源网站| 中文字幕精品无码久久久久久3D日动漫| 精品久久久久久国产牛牛app| 国内精品免费久久影院| 久久亚洲国产成人影院网站|