• <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 閱讀(239) 評論(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

            久久国产欧美日韩精品| 伊人情人综合成人久久网小说| 久久久九九有精品国产| 精品久久777| 久久综合久久久| 伊色综合久久之综合久久| 日韩人妻无码精品久久免费一| 2022年国产精品久久久久| 日本国产精品久久| 久久国产免费观看精品| 久久久久久久久66精品片| 久久精品国产亚洲网站| 久久国产免费直播| 久久久久国产精品| 香蕉久久夜色精品国产尤物| 99国产欧美久久久精品蜜芽| 青青久久精品国产免费看| 亚洲国产精品一区二区久久| 人人妻久久人人澡人人爽人人精品| 国产一级持黄大片99久久| 少妇内射兰兰久久| 欧美伊人久久大香线蕉综合| AA级片免费看视频久久| 99久久久精品| 77777亚洲午夜久久多喷| 亚洲国产另类久久久精品小说| 久久久久亚洲av成人无码电影 | 欧美久久精品一级c片片| 亚洲精品乱码久久久久久中文字幕| 久久精品综合一区二区三区| 免费观看久久精彩视频 | 国产成人精品久久一区二区三区av | 国产精品美女久久久久网| 久久久久亚洲av无码专区导航| 久久综合久久性久99毛片| 久久激情亚洲精品无码?V| 无码人妻久久一区二区三区蜜桃| 成人国内精品久久久久影院VR| 日本福利片国产午夜久久| 精品久久久无码中文字幕天天| 久久久国产一区二区三区|