Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void GUIManager::MouseHandler(Mouse & mouse)
- {
- while (!mouse.IsEmpty()) {
- Mouse::Event event = mouse.Read();
- bool overlap = false;
- for (auto& i : Elements) {
- switch (event.GetType()) {
- case Mouse::Event::LPress:
- if (i->IsEnabled()) {
- if (i->IsHover())
- {
- i->OnLeftPressed();
- }
- else {
- i->SetActive(false);
- }
- }
- break;
- case Mouse::Event::LRelease:
- if (i->IsEnabled()) {
- i->OnLeftReleased();
- }
- break;
- case Mouse::Event::Move:
- if (i->IsEnabled()) {
- if (i->OnMouseMove(mouse.GetPosX(), mouse.GetPosY())) {
- overlap = true;
- switch (i->GetType()) {
- case GUIElement::eType::TEXTINPUT:
- case GUIElement::eType::TEXTAREA:
- mouse.ChangeCursor(IDC_IBEAM);
- break;
- case GUIElement::eType::BUTTON:
- mouse.ChangeCursor(IDC_HAND);
- break;
- }
- }
- }
- break;
- }
- }
- if (!overlap) {
- mouse.ChangeCursor(IDC_ARROW);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment