WgWidget * WgPopupLayer::_findWidget( const WgCoord& ofs, WgSearchMode mode ) { // MenuPanel has its own _findWidget() method since we need special treatment of // searchmode ACTION_TARGET when a menu is open. if( mode == WG_SEARCH_ACTION_TARGET && !m_popupHooks.IsEmpty() ) { // In search mode ACTION_TARGET we limit our target to us, our menu-branches and the menu-opener if a menu is open. WgPopupHook * pHook = m_popupHooks.Last(); WgWidget * pResult = 0; while( pHook && !pResult ) { if( pHook->m_geo.Contains( ofs ) ) { if( pHook->_widget()->IsContainer() ) pResult = static_cast<WgContainer*>(pHook->_widget())->_findWidget( ofs - pHook->m_geo.Pos(), mode ); else if( pHook->_widget()->MarkTest( ofs - pHook->m_geo.Pos() ) ) pResult = pHook->_widget(); } pHook = pHook->_prev(); } if( pResult == 0 ) { // Check the first opener WgPopupHook * pHook = m_popupHooks.First(); if( pHook && pHook->m_pOpener ) { WgWidget * pOpener = pHook->m_pOpener.RawPtr(); WgCoord absPos = ofs + GlobalPos(); WgRect openerGeo = pOpener->GlobalGeo(); if( openerGeo.Contains(absPos) && pOpener->MarkTest( absPos - openerGeo.Pos() ) ) pResult = pOpener; } // Fall back to us. if( pResult == 0 ) pResult = this; } return pResult; } else { // For the rest of the modes we can rely on the default method. return WgContainer::_findWidget( ofs, mode ); } }