Guest User

Untitled

a guest
Jan 11th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. void GUIManager::MouseHandler(Mouse & mouse)
  2. {
  3.     while (!mouse.IsEmpty()) {
  4.         Mouse::Event event = mouse.Read();
  5.         bool overlap = false;
  6.         for (auto& i : Elements) {
  7.             switch (event.GetType()) {
  8.                 case Mouse::Event::LPress:
  9.                     if (i->IsEnabled()) {
  10.                         if (i->IsHover())
  11.                         {
  12.                             i->OnLeftPressed();
  13.                         }
  14.                         else {
  15.                             i->SetActive(false);
  16.                         }
  17.                     }
  18.                     break;
  19.                 case Mouse::Event::LRelease:
  20.                     if (i->IsEnabled()) {
  21.                         i->OnLeftReleased();
  22.                     }
  23.                     break;
  24.                 case Mouse::Event::Move:
  25.                     if (i->IsEnabled()) {
  26.                         if (i->OnMouseMove(mouse.GetPosX(), mouse.GetPosY())) {
  27.                             overlap = true;
  28.                             switch (i->GetType()) {
  29.                             case GUIElement::eType::TEXTINPUT:
  30.                             case GUIElement::eType::TEXTAREA:
  31.                                 mouse.ChangeCursor(IDC_IBEAM);
  32.                                 break;
  33.                             case GUIElement::eType::BUTTON:
  34.                                 mouse.ChangeCursor(IDC_HAND);
  35.                                 break;
  36.                             }
  37.                         }
  38.                     }
  39.                     break;
  40.             }
  41.         }
  42.         if (!overlap) {
  43.             mouse.ChangeCursor(IDC_ARROW);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment