Esempio n. 1
0
	void ModalLayer::_onMsg( const Msg_p& _pMsg )
	{
		Layer::_onMsg(_pMsg);
	
		if( !m_modalHooks.isEmpty() && _findWidget( _pMsg->pointerPos(), WG_SEARCH_ACTION_TARGET ) == this )
		{
			switch( _pMsg->type() )
			{
				case WG_MSG_MOUSE_PRESS:
				{
					MouseButtonMsg_p pMsg = MouseButtonMsg::cast(_pMsg);
					Base::msgRouter()->post( new ModalBlockedPressMsg( pMsg->button(), this) );
				}
				break;
	
				case WG_MSG_MOUSE_RELEASE:
				{
					MouseButtonMsg_p pMsg = MouseButtonMsg::cast(_pMsg);
					Base::msgRouter()->post( new ModalBlockedPressMsg( pMsg->button(), this) );
				}
				break;
	
				case WG_MSG_MOUSE_MOVE:
				{
					Base::msgRouter()->post( new ModalMoveOutsideMsg(this) );
				}
				break;
			}
		}	
	}
Esempio n. 2
0
void WgPopupLayer::_onEvent( const WgEventPtr& _pEvent, WgEventHandler * pHandler )
{
	WgLayer::_onEvent(_pEvent,pHandler);

	WgWidget * pOpener = 0;

	// Try to find an opener

	WgWidget * pOrigin = _pEvent->Widget();
	if( pOrigin && pOrigin != this )
	{
		WgPopupHook * pHook = m_popupHooks.First();
		while( pHook && pHook->_widget() != pOrigin )
			pHook = pHook->_next();
			
		if( pHook && pHook->m_pOpener )
			pOpener = pHook->m_pOpener.RawPtr();
	}
	
	// First we try to forward event to opener (if any)

	if( pOpener )
	{
		pHandler->ForwardEvent( _pEvent, pOpener );
		return;
	}	

	// Secondly we take care of event ourselves if it is addressed to one of our menus or us.

	switch( _pEvent->Type() )
	{
/*
		case WG_EVENT_MOUSE_POSITION:

			if( !m_popupHooks.IsEmpty() )							// Process only if we have at least one open menu.
			{
				WgCoord ofs = _pEvent->PointerPos();
				WgWidget * p = _findWidget( ofs, WG_SEARCH_ACTION_TARGET );
				if( p != this )
				{
					while( p->Parent() != this )
						p = p->Parent();
						
					if( p != m_popupHooks.	
				}	
			}
		break;
*/		
		case WG_EVENT_MOUSE_RELEASE:
		case WG_EVENT_MOUSE_PRESS:
		{
			WgMouseButtonEventPtr pEvent = WgMouseButtonEvent::Cast(_pEvent);

			WgCoord ofs = pEvent->PointerPos();
			WgWidget * p = _findWidget( ofs, WG_SEARCH_ACTION_TARGET );
			if( p == this )
			{
				CloseAllPopups();
				pHandler->SwallowEvent( _pEvent );
				return;
			}
		}
		break;

		case WG_EVENT_KEY_PRESS:
		case WG_EVENT_KEY_REPEAT:
		{
			WgKeyEventPtr pEvent = WgKeyEvent::Cast(_pEvent);

			if( pEvent->TranslatedKeyCode() == WG_KEY_ESCAPE )
			{
				if( !m_popupHooks.IsEmpty() )
				{
					ClosePopup( m_popupHooks.Last()->_widget() );
					pHandler->SwallowEvent( _pEvent );
					return;
				}
			}

		}
		break;
	}
}