Refactored input event handling a bit.

--HG--
branch : gui-editor
hg/feature/streamed-package
dfighter1985 11 years ago
parent b4a64d4c04
commit e12d189d51

@ -333,6 +333,12 @@ namespace NLGUI
bool handleEvent( const CEventDescriptor &evnt ); bool handleEvent( const CEventDescriptor &evnt );
bool handleSystemEvent( const CEventDescriptor &evnt );
bool handleKeyboardEvent( const CEventDescriptor &evnt );
bool handleMouseEvent( const CEventDescriptor &evnt );
bool handleMouseMoveEvent( const CEventDescriptor &eventDesc ); bool handleMouseMoveEvent( const CEventDescriptor &eventDesc );
// Relative move of pointer // Relative move of pointer

@ -2096,456 +2096,478 @@ namespace NLGUI
if( activeAnims[i]->isDisableButtons() ) if( activeAnims[i]->isDisableButtons() )
return false; return false;
bool handled = false;
CViewPointer *_Pointer = static_cast< CViewPointer* >( getPointer() );
if( evnt.getType() == CEventDescriptor::system ) if( evnt.getType() == CEventDescriptor::system )
{ {
const CEventDescriptorSystem &systemEvent = reinterpret_cast< const CEventDescriptorSystem& >( evnt ); handleSystemEvent( evnt );
if( systemEvent.getEventTypeExtended() == CEventDescriptorSystem::setfocus ) }
else
if (evnt.getType() == CEventDescriptor::key)
{
handled = handleKeyboardEvent( evnt );
}
else if (evnt.getType() == CEventDescriptor::mouse )
{
handled = handleMouseEvent( evnt );
}
CDBManager::getInstance()->flushObserverCalls();
return handled;
}
bool CWidgetManager::handleSystemEvent( const CEventDescriptor &evnt )
{
const CEventDescriptorSystem &systemEvent = reinterpret_cast< const CEventDescriptorSystem& >( evnt );
if( systemEvent.getEventTypeExtended() == CEventDescriptorSystem::setfocus )
{
if( getCapturePointerLeft() != NULL )
{ {
if( getCapturePointerLeft() != NULL ) getCapturePointerLeft()->handleEvent( evnt );
{ setCapturePointerLeft( NULL );
getCapturePointerLeft()->handleEvent( evnt ); }
setCapturePointerLeft( NULL );
}
if( getCapturePointerRight() != NULL ) if( getCapturePointerRight() != NULL )
{ {
getCapturePointerRight()->handleEvent( evnt ); getCapturePointerRight()->handleEvent( evnt );
setCapturePointerRight( NULL ); setCapturePointerRight( NULL );
} }
if( _CapturedView != NULL ) if( _CapturedView != NULL )
{ {
_CapturedView->handleEvent( evnt ); _CapturedView->handleEvent( evnt );
_CapturedView = NULL; _CapturedView = NULL;
}
} }
} }
return true;
}
bool CWidgetManager::handleKeyboardEvent( const CEventDescriptor &evnt )
{
bool handled = false; bool handled = false;
CViewPointer *_Pointer = static_cast< CViewPointer* >( getPointer() ); CEventDescriptorKey &eventDesc = (CEventDescriptorKey&)evnt;
if (evnt.getType() == CEventDescriptor::key) //_LastEventKeyDesc = eventDesc;
{
CEventDescriptorKey &eventDesc = (CEventDescriptorKey&)evnt;
//_LastEventKeyDesc = eventDesc;
// Any Key event disable the ContextHelp // Any Key event disable the ContextHelp
disableContextHelp(); disableContextHelp();
// Hide menu if the key is pushed // Hide menu if the key is pushed
// if ((eventDesc.getKeyEventType() == CEventDescriptorKey::keydown) && !_ModalStack.empty() && !eventDesc.getKeyAlt() && !eventDesc.getKeyCtrl() && !eventDesc.getKeyShift()) // if ((eventDesc.getKeyEventType() == CEventDescriptorKey::keydown) && !_ModalStack.empty() && !eventDesc.getKeyAlt() && !eventDesc.getKeyCtrl() && !eventDesc.getKeyShift())
// Hide menu (or popup menu) is ESCAPE pressed // Hide menu (or popup menu) is ESCAPE pressed
if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyESCAPE ) if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyESCAPE )
{
if( hasModal() )
{ {
if( hasModal() ) SModalWndInfo mwi = getModal();
{ if (mwi.ModalExitKeyPushed)
SModalWndInfo mwi = getModal(); disableModalWindow();
if (mwi.ModalExitKeyPushed)
disableModalWindow();
}
} }
}
// Manage "quit window" If the Key is ESCAPE, no captureKeyboard // Manage "quit window" If the Key is ESCAPE, no captureKeyboard
if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyESCAPE ) if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyESCAPE )
{
// Get the last escapable active top window. NB: this is ergonomically better.
CInterfaceGroup *win= getLastEscapableTopWindow();
if( win )
{ {
// Get the last escapable active top window. NB: this is ergonomically better. // If the window is a modal, must pop it.
CInterfaceGroup *win= getLastEscapableTopWindow(); if( dynamic_cast<CGroupModal*>(win) )
if( win )
{ {
// If the window is a modal, must pop it. if(!win->getAHOnEscape().empty())
if( dynamic_cast<CGroupModal*>(win) ) CAHManager::getInstance()->runActionHandler(win->getAHOnEscape(), win, win->getAHOnEscapeParams());
{ popModalWindow();
if(!win->getAHOnEscape().empty()) handled= true;
CAHManager::getInstance()->runActionHandler(win->getAHOnEscape(), win, win->getAHOnEscapeParams()); }
popModalWindow(); // else just disable it.
handled= true; // Special case: leave the escape Key to the CaptureKeyboard .
} else if( !getCaptureKeyboard() )
// else just disable it. {
// Special case: leave the escape Key to the CaptureKeyboard . if(!win->getAHOnEscape().empty())
else if( !getCaptureKeyboard() ) CAHManager::getInstance()->runActionHandler(win->getAHOnEscape(), win, win->getAHOnEscapeParams());
{ win->setActive(false);
if(!win->getAHOnEscape().empty()) handled= true;
CAHManager::getInstance()->runActionHandler(win->getAHOnEscape(), win, win->getAHOnEscapeParams());
win->setActive(false);
handled= true;
}
} }
} }
}
// Manage complex "Enter" // Manage complex "Enter"
if (eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyRETURN) if (eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyRETURN)
{
// If the top window has Enter AH
CInterfaceGroup *tw= getTopWindow();
if(tw && !tw->getAHOnEnter().empty())
{ {
// If the top window has Enter AH // if the captured keyboard is in this Modal window, then must handle him in priority
CInterfaceGroup *tw= getTopWindow(); if( getCaptureKeyboard() && getCaptureKeyboard()->getRootWindow()==tw)
if(tw && !tw->getAHOnEnter().empty())
{ {
// if the captured keyboard is in this Modal window, then must handle him in priority bool result = getCaptureKeyboard()->handleEvent(evnt);
if( getCaptureKeyboard() && getCaptureKeyboard()->getRootWindow()==tw) CDBManager::getInstance()->flushObserverCalls();
{ return result;
bool result = getCaptureKeyboard()->handleEvent(evnt); }
CDBManager::getInstance()->flushObserverCalls(); else
return result; {
} // The window or modal control the OnEnter. Execute, and don't go to the chat.
else CAHManager::getInstance()->runActionHandler(tw->getAHOnEnter(), tw, tw->getAHOnEnterParams());
{ handled= true;
// The window or modal control the OnEnter. Execute, and don't go to the chat.
CAHManager::getInstance()->runActionHandler(tw->getAHOnEnter(), tw, tw->getAHOnEnterParams());
handled= true;
}
} }
}
// else the 'return' key bring back to the last edit box (if possible) // else the 'return' key bring back to the last edit box (if possible)
CCtrlBase *oldCapture = getOldCaptureKeyboard() ? getOldCaptureKeyboard() : getDefaultCaptureKeyboard(); CCtrlBase *oldCapture = getOldCaptureKeyboard() ? getOldCaptureKeyboard() : getDefaultCaptureKeyboard();
if ( getCaptureKeyboard() == NULL && oldCapture && !handled) if ( getCaptureKeyboard() == NULL && oldCapture && !handled)
{
/* If the editbox does not want to recover focus, then abort. This possibility is normaly avoided
through setCaptureKeyboard() which already test getRecoverFocusOnEnter(), but it is still possible
for the default capture (main chat) or the old captured window to not want to recover
(temporary Read Only chat for instance)
*/
if(!dynamic_cast<CGroupEditBoxBase*>(oldCapture) ||
dynamic_cast<CGroupEditBoxBase*>(oldCapture)->getRecoverFocusOnEnter())
{ {
/* If the editbox does not want to recover focus, then abort. This possibility is normaly avoided setCaptureKeyboard( oldCapture );
through setCaptureKeyboard() which already test getRecoverFocusOnEnter(), but it is still possible notifyElementCaptured(getCaptureKeyboard() );
for the default capture (main chat) or the old captured window to not want to recover // make sure all parent windows are active
(temporary Read Only chat for instance) CCtrlBase *cb = getCaptureKeyboard();
*/ CGroupContainer *lastContainer = NULL;
if(!dynamic_cast<CGroupEditBoxBase*>(oldCapture) || for(;;)
dynamic_cast<CGroupEditBoxBase*>(oldCapture)->getRecoverFocusOnEnter())
{ {
setCaptureKeyboard( oldCapture ); CGroupContainer *gc = dynamic_cast<CGroupContainer *>(cb);
notifyElementCaptured(getCaptureKeyboard() ); if (gc) lastContainer = gc;
// make sure all parent windows are active cb->forceOpen();
CCtrlBase *cb = getCaptureKeyboard(); if (cb->getParent())
CGroupContainer *lastContainer = NULL;
for(;;)
{ {
CGroupContainer *gc = dynamic_cast<CGroupContainer *>(cb); cb = cb->getParent();
if (gc) lastContainer = gc;
cb->forceOpen();
if (cb->getParent())
{
cb = cb->getParent();
}
else
{
cb->invalidateCoords();
break;
}
} }
if (lastContainer) else
{ {
setTopWindow(lastContainer); cb->invalidateCoords();
lastContainer->enableBlink(1); break;
} }
handled= true;
} }
if (lastContainer)
{
setTopWindow(lastContainer);
lastContainer->enableBlink(1);
}
handled= true;
} }
} }
}
// General case: handle it in the Captured keyboard // General case: handle it in the Captured keyboard
if ( getCaptureKeyboard() != NULL && !handled) if ( getCaptureKeyboard() != NULL && !handled)
{ {
bool result = getCaptureKeyboard()->handleEvent(evnt); bool result = getCaptureKeyboard()->handleEvent(evnt);
CDBManager::getInstance()->flushObserverCalls(); CDBManager::getInstance()->flushObserverCalls();
return result; return result;
}
lastKeyEvent = eventDesc;
} }
//////////////////////////////////////////////// Keyboard handling ends here //////////////////////////////////// lastKeyEvent = eventDesc;
else if (evnt.getType() == CEventDescriptor::mouse ) return handled;
{ }
CEventDescriptorMouse &eventDesc = (CEventDescriptorMouse&)evnt;
if( eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown ) bool CWidgetManager::handleMouseEvent( const CEventDescriptor &evnt )
_Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() | NLMISC::leftButton ) ); {
else bool handled = false;
if( eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown )
_Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() | NLMISC::rightButton ) );
else
if( eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup )
_Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() & ~NLMISC::leftButton ) );
if( eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup )
_Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() & ~NLMISC::rightButton ) );
if( eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove ) CEventDescriptorMouse &eventDesc = (CEventDescriptorMouse&)evnt;
handleMouseMoveEvent( eventDesc );
eventDesc.setX( _Pointer->getX() ); if( eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown )
eventDesc.setY( _Pointer->getY() ); _Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() | NLMISC::leftButton ) );
else
if( eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown )
_Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() | NLMISC::rightButton ) );
else
if( eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup )
_Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() & ~NLMISC::leftButton ) );
if( eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup )
_Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() & ~NLMISC::rightButton ) );
if( isMouseHandlingEnabled() ) if( eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove )
{ handleMouseMoveEvent( eventDesc );
// First thing to do : Capture handling
if ( getCapturePointerLeft() != NULL)
handled|= getCapturePointerLeft()->handleEvent(evnt);
if ( getCapturePointerRight() != NULL && eventDesc.setX( _Pointer->getX() );
getCapturePointerLeft() != getCapturePointerRight() ) eventDesc.setY( _Pointer->getY() );
handled|= getCapturePointerRight()->handleEvent(evnt);
if( _CapturedView != NULL ) if( isMouseHandlingEnabled() )
_CapturedView->handleEvent( evnt ); {
// First thing to do : Capture handling
if ( getCapturePointerLeft() != NULL)
handled|= getCapturePointerLeft()->handleEvent(evnt);
CInterfaceGroup *ptr = getWindowUnder (eventDesc.getX(), eventDesc.getY()); if ( getCapturePointerRight() != NULL &&
setCurrentWindowUnder( ptr ); getCapturePointerLeft() != getCapturePointerRight() )
handled|= getCapturePointerRight()->handleEvent(evnt);
// Any Mouse event but move disable the ContextHelp if( _CapturedView != NULL )
if(eventDesc.getEventTypeExtended() != CEventDescriptorMouse::mousemove) _CapturedView->handleEvent( evnt );
{
disableContextHelp();
}
// get the group under the mouse CInterfaceGroup *ptr = getWindowUnder (eventDesc.getX(), eventDesc.getY());
CInterfaceGroup *pNewCurrentWnd = getCurrentWindowUnder(); setCurrentWindowUnder( ptr );
setMouseOverWindow( pNewCurrentWnd != NULL );
// Any Mouse event but move disable the ContextHelp
if(eventDesc.getEventTypeExtended() != CEventDescriptorMouse::mousemove)
{
disableContextHelp();
}
NLMISC::CRefPtr<CGroupModal> clickedOutModalWindow; // get the group under the mouse
CInterfaceGroup *pNewCurrentWnd = getCurrentWindowUnder();
setMouseOverWindow( pNewCurrentWnd != NULL );
// modal special features
if ( hasModal() ) NLMISC::CRefPtr<CGroupModal> clickedOutModalWindow;
// modal special features
if ( hasModal() )
{
CWidgetManager::SModalWndInfo mwi = getModal();
if(mwi.ModalWindow)
{ {
CWidgetManager::SModalWndInfo mwi = getModal(); // If we are not in "click out" mode so we dont handle controls other than those of the modal
if(mwi.ModalWindow) if (pNewCurrentWnd != mwi.ModalWindow && !mwi.ModalExitClickOut)
{ {
// If we are not in "click out" mode so we dont handle controls other than those of the modal pNewCurrentWnd = NULL;
if (pNewCurrentWnd != mwi.ModalWindow && !mwi.ModalExitClickOut) }
{ else
pNewCurrentWnd = NULL; {
} // If there is a handler on click out launch it
else if (pNewCurrentWnd != mwi.ModalWindow)
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown ||
(eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown))
if (!mwi.ModalHandlerClickOut.empty())
CAHManager::getInstance()->runActionHandler(mwi.ModalHandlerClickOut,NULL,mwi.ModalClickOutParams);
// If the current window is not the modal and if must quit on click out
if(pNewCurrentWnd != mwi.ModalWindow && mwi.ModalExitClickOut)
{ {
// If there is a handler on click out launch it // NB: don't force handle==true because to quit a modal does not avoid other actions
if (pNewCurrentWnd != mwi.ModalWindow)
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown ||
(eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown))
if (!mwi.ModalHandlerClickOut.empty())
CAHManager::getInstance()->runActionHandler(mwi.ModalHandlerClickOut,NULL,mwi.ModalClickOutParams);
// If the current window is not the modal and if must quit on click out
if(pNewCurrentWnd != mwi.ModalWindow && mwi.ModalExitClickOut)
{
// NB: don't force handle==true because to quit a modal does not avoid other actions
// quit if click outside // quit if click outside
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown || if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown ||
(eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown)) (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown))
{
clickedOutModalWindow = dynamic_cast<CGroupModal *>((CInterfaceGroup*)mwi.ModalWindow);
// disable the modal
popModalWindow();
if ( hasModal() )
{ {
clickedOutModalWindow = dynamic_cast<CGroupModal *>((CInterfaceGroup*)mwi.ModalWindow); // don't handle event unless it is a previous modal window
// disable the modal if( !isPreviousModal( pNewCurrentWnd ) )
popModalWindow(); pNewCurrentWnd = NULL; // can't handle event before we have left all modal windows
if ( hasModal() )
{
// don't handle event unless it is a previous modal window
if( !isPreviousModal( pNewCurrentWnd ) )
pNewCurrentWnd = NULL; // can't handle event before we have left all modal windows
}
movePointer (0,0); // Reget controls under pointer
} }
movePointer (0,0); // Reget controls under pointer
} }
} }
} }
} }
}
// Manage LeftClick. // Manage LeftClick.
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown)
{
if ((pNewCurrentWnd != NULL) && (!hasModal()) && (pNewCurrentWnd->getOverlappable()))
{ {
if ((pNewCurrentWnd != NULL) && (!hasModal()) && (pNewCurrentWnd->getOverlappable())) CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(pNewCurrentWnd);
if (pGC != NULL)
{ {
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(pNewCurrentWnd); if (!pGC->isGrayed()) setTopWindow(pNewCurrentWnd);
if (pGC != NULL) }
{ else
if (!pGC->isGrayed()) setTopWindow(pNewCurrentWnd); {
} setTopWindow(pNewCurrentWnd);
else
{
setTopWindow(pNewCurrentWnd);
}
} }
}
bool captured = false; bool captured = false;
// must not capture a new element if a sheet is currentlty being dragged. // must not capture a new element if a sheet is currentlty being dragged.
// This may happen when alt-tab has been used => the sheet is dragged but the left button is up // This may happen when alt-tab has been used => the sheet is dragged but the left button is up
if (!CCtrlDraggable::getDraggedSheet()) if (!CCtrlDraggable::getDraggedSheet())
{
// Take the top most control.
uint nMaxDepth = 0;
const std::vector< CCtrlBase* >& _CtrlsUnderPointer = getCtrlsUnderPointer();
for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--)
{ {
// Take the top most control. CCtrlBase *ctrl= _CtrlsUnderPointer[i];
uint nMaxDepth = 0; if (ctrl && ctrl->isCapturable() && ctrl->isInGroup( pNewCurrentWnd ) )
const std::vector< CCtrlBase* >& _CtrlsUnderPointer = getCtrlsUnderPointer();
for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--)
{ {
CCtrlBase *ctrl= _CtrlsUnderPointer[i]; uint d = ctrl->getDepth( pNewCurrentWnd );
if (ctrl && ctrl->isCapturable() && ctrl->isInGroup( pNewCurrentWnd ) ) if (d > nMaxDepth)
{ {
uint d = ctrl->getDepth( pNewCurrentWnd ); nMaxDepth = d;
if (d > nMaxDepth) setCapturePointerLeft( ctrl );
{ captured = true;
nMaxDepth = d;
setCapturePointerLeft( ctrl );
captured = true;
}
} }
} }
}
if( CInterfaceElement::getEditorMode() && !captured ) if( CInterfaceElement::getEditorMode() && !captured )
{
for( sint32 i = _ViewsUnderPointer.size()-1; i >= 0; i-- )
{ {
for( sint32 i = _ViewsUnderPointer.size()-1; i >= 0; i-- ) CViewBase *v = _ViewsUnderPointer[i];
if( ( v != NULL ) && v->isInGroup( pNewCurrentWnd ) )
{ {
CViewBase *v = _ViewsUnderPointer[i]; _CapturedView = v;
if( ( v != NULL ) && v->isInGroup( pNewCurrentWnd ) ) captured = true;
{ break;
_CapturedView = v;
captured = true;
break;
}
} }
} }
notifyElementCaptured( getCapturePointerLeft() );
if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty())
{
CAHManager::getInstance()->runActionHandler(clickedOutModalWindow->OnPostClickOut, getCapturePointerLeft(), clickedOutModalWindow->OnPostClickOutParams);
}
} }
//if found
if ( captured )
{
// consider clicking on a control implies handling of the event.
handled= true;
// handle the capture notifyElementCaptured( getCapturePointerLeft() );
if( getCapturePointerLeft() != NULL ) if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty())
getCapturePointerLeft()->handleEvent(evnt); {
else CAHManager::getInstance()->runActionHandler(clickedOutModalWindow->OnPostClickOut, getCapturePointerLeft(), clickedOutModalWindow->OnPostClickOutParams);
_CapturedView->handleEvent( evnt );
} }
} }
//if found
if ( captured )
{
// consider clicking on a control implies handling of the event.
handled= true;
// Manage RightClick // handle the capture
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown) if( getCapturePointerLeft() != NULL )
getCapturePointerLeft()->handleEvent(evnt);
else
_CapturedView->handleEvent( evnt );
}
}
// Manage RightClick
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown)
{
if ((pNewCurrentWnd != NULL) && (!hasModal()) && (pNewCurrentWnd->getOverlappable()))
{ {
if ((pNewCurrentWnd != NULL) && (!hasModal()) && (pNewCurrentWnd->getOverlappable())) CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(pNewCurrentWnd);
if (pGC != NULL)
{ {
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(pNewCurrentWnd); if (!pGC->isGrayed()) setTopWindow(pNewCurrentWnd);
if (pGC != NULL) }
{ else
if (!pGC->isGrayed()) setTopWindow(pNewCurrentWnd); {
} setTopWindow(pNewCurrentWnd);
else
{
setTopWindow(pNewCurrentWnd);
}
} }
}
// Take the top most control. // Take the top most control.
{
uint nMaxDepth = 0;
const std::vector< CCtrlBase* >& _CtrlsUnderPointer = getCtrlsUnderPointer();
for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--)
{ {
uint nMaxDepth = 0; CCtrlBase *ctrl= _CtrlsUnderPointer[i];
const std::vector< CCtrlBase* >& _CtrlsUnderPointer = getCtrlsUnderPointer(); if (ctrl && ctrl->isCapturable() && ctrl->isInGroup( pNewCurrentWnd ) )
for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--)
{ {
CCtrlBase *ctrl= _CtrlsUnderPointer[i]; uint d = ctrl->getDepth( pNewCurrentWnd );
if (ctrl && ctrl->isCapturable() && ctrl->isInGroup( pNewCurrentWnd ) ) if (d > nMaxDepth)
{ {
uint d = ctrl->getDepth( pNewCurrentWnd ); nMaxDepth = d;
if (d > nMaxDepth) setCapturePointerRight( ctrl );
{
nMaxDepth = d;
setCapturePointerRight( ctrl );
}
} }
} }
notifyElementCaptured( getCapturePointerRight() );
if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty())
{
CAHManager::getInstance()->runActionHandler(clickedOutModalWindow->OnPostClickOut, getCapturePointerRight(), clickedOutModalWindow->OnPostClickOutParams);
}
} }
//if found notifyElementCaptured( getCapturePointerRight() );
if ( getCapturePointerRight() != NULL) if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty())
{ {
// handle the capture CAHManager::getInstance()->runActionHandler(clickedOutModalWindow->OnPostClickOut, getCapturePointerRight(), clickedOutModalWindow->OnPostClickOutParams);
handled |= getCapturePointerRight()->handleEvent(evnt);
} }
} }
//if found
if ( getCapturePointerRight() != NULL)
{
// handle the capture
handled |= getCapturePointerRight()->handleEvent(evnt);
}
}
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup) if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup)
{
if (!handled)
if (pNewCurrentWnd != NULL)
pNewCurrentWnd->handleEvent(evnt);
if ( getCapturePointerRight() != NULL)
{ {
if (!handled) setCapturePointerRight(NULL);
if (pNewCurrentWnd != NULL) handled= true;
pNewCurrentWnd->handleEvent(evnt);
if ( getCapturePointerRight() != NULL)
{
setCapturePointerRight(NULL);
handled= true;
}
} }
}
// window handling. if not handled by a control // window handling. if not handled by a control
if (!handled) if (!handled)
{
if (((pNewCurrentWnd != NULL) && !hasModal()) ||
((hasModal() && getModal().ModalWindow == pNewCurrentWnd)))
{ {
if (((pNewCurrentWnd != NULL) && !hasModal()) || CEventDescriptorMouse ev2 = eventDesc;
((hasModal() && getModal().ModalWindow == pNewCurrentWnd))) sint32 x= eventDesc.getX(), y = eventDesc.getY();
if (pNewCurrentWnd)
{ {
CEventDescriptorMouse ev2 = eventDesc; pNewCurrentWnd->absoluteToRelative (x, y);
sint32 x= eventDesc.getX(), y = eventDesc.getY(); ev2.setX (x); ev2.setY (y);
if (pNewCurrentWnd) handled|= pNewCurrentWnd->handleEvent (ev2);
{
pNewCurrentWnd->absoluteToRelative (x, y);
ev2.setX (x); ev2.setY (y);
handled|= pNewCurrentWnd->handleEvent (ev2);
}
// After handle event of a left click, may set window Top if movable (infos etc...)
//if( (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) && pNewCurrentWnd->isMovable() )
// setTopWindow(pNewCurrentWnd);
} }
// After handle event of a left click, may set window Top if movable (infos etc...)
//if( (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) && pNewCurrentWnd->isMovable() )
// setTopWindow(pNewCurrentWnd);
} }
}
// Put here to let a chance to the window to handle if the capture dont // Put here to let a chance to the window to handle if the capture dont
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup)
{
if ( getCapturePointerLeft() != NULL)
{ {
if ( getCapturePointerLeft() != NULL) setCapturePointerLeft(NULL);
{ handled = true;
setCapturePointerLeft(NULL);
handled = true;
}
} }
}
// If the current window is the modal, may Modal quit. Do it after standard event handle // If the current window is the modal, may Modal quit. Do it after standard event handle
if(hasModal() && pNewCurrentWnd == getModal().ModalWindow) if(hasModal() && pNewCurrentWnd == getModal().ModalWindow)
{
// NB: don't force handle==true because to quit a modal does not avoid other actions
CWidgetManager::SModalWndInfo mwi = getModal();
// and if must quit on click right
if(mwi.ModalExitClickR)
{ {
// NB: don't force handle==true because to quit a modal does not avoid other actions // quit if click right
CWidgetManager::SModalWndInfo mwi = getModal(); if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup)
// and if must quit on click right // disable the modal
if(mwi.ModalExitClickR) disableModalWindow();
{
// quit if click right
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup)
// disable the modal
disableModalWindow();
}
// and if must quit on click left
if(mwi.ModalExitClickL)
{
// quit if click right
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup)
// disable the modal
disableModalWindow();
}
} }
// If the mouse is over a window, always consider the event is taken (avoid click behind) // and if must quit on click left
handled|= isMouseOverWindow(); if(mwi.ModalExitClickL)
{
// quit if click right
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup)
// disable the modal
disableModalWindow();
}
} }
}
CDBManager::getInstance()->flushObserverCalls(); // If the mouse is over a window, always consider the event is taken (avoid click behind)
handled|= isMouseOverWindow();
}
return handled; return handled;
} }
bool CWidgetManager::handleMouseMoveEvent( const CEventDescriptor &eventDesc ) bool CWidgetManager::handleMouseMoveEvent( const CEventDescriptor &eventDesc )
{ {
if( getPointer() == NULL ) if( getPointer() == NULL )

Loading…
Cancel
Save