Ejemplo n.º 1
0
bool nuiContainer::DispatchMouseUnclick(const nglMouseInfo& rInfo)
{
  CheckValid();
  nuiAutoRef;
  if (!mMouseEventEnabled || mTrashed)
    return false;

  bool hasgrab = HasGrab(rInfo.TouchId);
  if (IsDisabled() && !hasgrab)
    return false;

  nglMouseInfo info(rInfo);
  GlobalToLocal(info.X, info.Y);
  // Get a chance to preempt the mouse event before the children get it:
  if (PreMouseUnclicked(info))
  {
    Ungrab();
    return true;
  }
  
  if (IsInsideFromRoot(rInfo.X, rInfo.Y) || hasgrab)
  {
    if (!hasgrab)
    {
      IteratorPtr pIt;
      for (pIt = GetLastChild(false); pIt && pIt->IsValid(); GetPreviousChild(pIt))
      {
        nuiWidgetPtr pItem = pIt->GetWidget();
        if (pItem)
        {
          if (IsEnabled())
          {
            if ((pItem)->DispatchMouseUnclick(rInfo))
            {
              delete pIt;
              return true;
            }
          }
        }
      }
      delete pIt;
    }

    bool res = PreUnclicked(info);
    if (!res)
    {
      res = MouseUnclicked(info);
      res |= Unclicked(info);
    }

    res = res | (!mClickThru);
    if (res)
      Ungrab();
    return res;
  }
  return false;
}
Ejemplo n.º 2
0
bool nuiWindowManager::DispatchMouseClick(const nglMouseInfo& rInfo)
{
  if (!IsEnabled())
    return false;

  if (IsInsideFromRoot(rInfo.X, rInfo.Y))
  {
    if (!mWindows.empty())
    {
      std::list<nuiWindow*>::iterator it;
      std::list<nuiWindow*>::iterator begin = mWindows.begin();
      it = mWindows.end();
      do 
      {
        it--;
        nuiWindow* win = *it;
        if (win->IsInsideFromRoot(rInfo.X, rInfo.Y))
        {
          if (GetActiveWindow() != win)
            ActivateWindow(win);
          break;
        }
      } while (it!=begin);
    }

    IteratorPtr pIt;
    for (pIt = GetLastChild(); pIt && pIt->IsValid(); GetPreviousChild(pIt))
    {
      nuiWidgetPtr pItem = pIt->GetWidget();
      if (pItem && pItem->IsVisible() && pItem->IsEnabled())
      {
        if (pItem->DispatchMouseClick(rInfo))
        {
          delete pIt;
          return true;
        }
      }
    }
    delete pIt;

    nglMouseInfo info(rInfo);
    GlobalToLocal(info.X, info.Y);
    bool ret = MouseClicked(info);
    ret |= Clicked(info);
    return ret;
  }
  return false;
}
Ejemplo n.º 3
0
nuiWidgetPtr nuiContainer::DispatchMouseMove(const nglMouseInfo& rInfo)
{
  CheckValid();
  nuiAutoRef;
  if (!mMouseEventEnabled || mTrashed)
    return false;

  nuiWidgetPtr pHandled=NULL;
  bool inside=false,res=false;
  bool hasgrab = HasGrab(rInfo.TouchId);

  if (IsDisabled() && !hasgrab)
    return NULL;

  nglMouseInfo info(rInfo);
  GlobalToLocal(info.X, info.Y);

  // Get a chance to preempt the mouse event before the children get it:
  if (PreMouseMoved(info))
    return this;
  
  if (IsInsideFromRoot(rInfo.X, rInfo.Y) || hasgrab)
  {
    inside = true;

    // If the object has the grab we should not try to notify its children of mouse events!
    if (!hasgrab) 
    {

      IteratorPtr pIt;
      for (pIt = GetLastChild(false); pIt && pIt->IsValid(); GetPreviousChild(pIt))
      {
        nuiWidgetPtr pItem = pIt->GetWidget();
        if (pItem)
        {
          if (pItem->IsVisible())
          {
            pHandled = pItem->DispatchMouseMove(rInfo);
          } 
        }
        if (pHandled)
        {
          // stop as soon as someone caught the event
          delete pIt;
          return pHandled;
        }
      }
      delete pIt;
    }

    res = MouseMoved(info);
    res |= MovedMouse(info);
  }
  else
  {
    if (GetHover())
    {
      res = MouseMoved(info);
      res |= MovedMouse(info);
    }
  }

  if (!pHandled && (res | (!mClickThru)) && inside)
  {
    nuiTopLevelPtr pRoot = GetTopLevel();
    if (pRoot)
      return this;
  }

  if (pHandled)
    return pHandled;

  return (res && inside) ? this : NULL;
}