예제 #1
0
void muiWindow::OnMouseButton(int nButton, eMouseButtonAction eAction, muiCoord xyPos, WPARAM fKeys)
{
	/*if ((nButton == 1) && (eAction == eButtonUp)) {
		ClientToScreen(xyPos);
		OnContextMenu(xyPos, nButton);
	}*/

	if (!s_nPopupWindows) return;

	bool bInsideMenu = false;
	for (int n = 0; n < s_nPopupWindows; n++) {
		HWND hwndPopup = aPopupWindows[n]->WindowHandle();
		if ((hwndPopup == hwnd) || ::IsChild(hwndPopup, hwnd)) {
			bInsideMenu = true;
		}
	}

	if (!bInsideMenu) CloseAllPopups();
}
예제 #2
0
void muiWindow::OnActivateApp(bool bItIsThisApp)
{
	if (!bItIsThisApp) CloseAllPopups();
}
예제 #3
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;
	}
}