bool iWidget::ProcessMessage(eGuiMessage a_Message, cGuiMessageData &a_Data) { if (IsEnabled()==false) return false; a_Data.m_Message = a_Message; bool bRet = false; bRet = OnMessage(a_Message, a_Data); if (bRet==false) { switch(a_Message) { case eGuiMessage_MouseMove: bRet = OnMouseMove(a_Data);break; case eGuiMessage_MouseDown: bRet = OnMouseDown(a_Data);break; case eGuiMessage_MouseUp: bRet = OnMouseUp(a_Data);break; case eGuiMessage_MouseDoubleClick: bRet = OnMouseDoubleClick(a_Data);break; case eGuiMessage_MouseEnter: bRet = OnMouseEnter(a_Data);break; case eGuiMessage_MouseLeave: bRet = OnMouseLeave(a_Data);break; case eGuiMessage_GotFocus: bRet = OnGotFocus(a_Data);break; case eGuiMessage_LostFocus: bRet = OnLostFocus(a_Data);break; case eGuiMessage_KeyPress: bRet = OnKeyPress(a_Data);break; } } if (ProcessCallbacks(a_Message, a_Data)) bRet = true; return bRet; }
bool iWidget::ProcessMessage(eGuiMessage aMessage, cGuiMessageData &aData) { if(IsEnabled()==false) return false; aData.mMessage = aMessage; bool bRet = false; bRet = OnMessage(aMessage,aData); //This can override any message. ///////////////////////////////////////// //Call the correct virtual function if(bRet==false) { switch(aMessage) { case eGuiMessage_MouseMove: bRet = OnMouseMove(aData); break; case eGuiMessage_MouseDown: bRet = OnMouseDown(aData); break; case eGuiMessage_MouseUp: bRet = OnMouseUp(aData); break; case eGuiMessage_MouseDoubleClick: bRet = OnMouseDoubleClick(aData); break; case eGuiMessage_MouseEnter: bRet = OnMouseEnter(aData); break; case eGuiMessage_MouseLeave: bRet = OnMouseLeave(aData); break; case eGuiMessage_KeyPress: bRet = OnKeyPress(aData); break; case eGuiMessage_GotFocus: bRet = OnGotFocus(aData); break; case eGuiMessage_LostFocus: bRet = OnLostFocus(aData); break; } } ///////////////////////////////////////// //Process user callbacks for the event. if(ProcessCallbacks(aMessage,aData)) bRet = true; return bRet; }
void Button::MouseEntered(const MouseEvent& lEvent) { if(IsDisabled()) { return; } SetHover(true); OnMouseEnter(); // Call the callback function if(m_EnterCallback) { m_EnterCallback(m_pEnterCallbackData); } if(m_bChangeLabelText) { for(unsigned int i = 0; i < m_vpAddedComponentList.size(); i++) { if(m_vpAddedComponentList[i]->GetComponentType() == EComponentType_Label) { ((Label*)m_vpAddedComponentList[i])->SetColour(m_hoverLabelColour); } } m_label.SetColour(m_hoverLabelColour); } }
void Slider::MouseEntered(const MouseEvent& lEvent) { m_bDragginOutside = false; m_bFirstOutsideDrag = false; OnMouseEnter(); }
void OUGUIObject::SetMouseEnter(bool bEnter) { if(bEnter == m_bMouseEnter) return; m_bMouseEnter = bEnter; if(m_bMouseEnter) OnMouseEnter(); else OnMouseLeave(); }
bool CGUITextBox::HandleMouse( UINT uMsg, WPARAM wParam, LPARAM lParam ) { GetCursorPos(&m_MousePos); switch(uMsg){ case WM_MOUSEMOVE: if(!m_bMouseOver && PtInBB(m_MousePos) && GetVisible()){ OnMouseEnter(); }if(m_bMouseOver && !PtInBB(m_MousePos)){ OnMouseLeave(); } if(m_bButtonDown) PlaceCaret(m_MousePos); break; case WM_LBUTTONDOWN: if(m_bMouseOver){ if(!m_bButtonDown){ if(GetFocus() || RequestFocus()) m_bButtonDown=true; } PlaceCaret(m_MousePos); if( GetKeyState( VK_SHIFT ) >= 0 ) SyncSelStart(); return true; } break; case WM_LBUTTONUP: m_bButtonDown=false; break; case WM_MOUSEWHEEL: if(m_bMouseOver){ if((int)wParam>0){//Scroll Up m_Scrolly=max((int)m_Scrolly-1, 0); }else{ m_Scrolly=min((int)m_Scrolly+1, max((int)m_MaxCarety-((int)(m_height/13))+1, 0)); } //m_Scrollx=min(max(m_Scrollx, 0), m_MaxCaretx+((int)(width/8))); SetTextDraw(); } break; } if(m_bMouseOver) return true; return false; }
bool CGUIHorizontalScrollBar::HandleMouse( UINT uMsg, WPARAM wParam, LPARAM lParam ) { POINT MousePos; GetCursorPos(&MousePos); switch(uMsg){ case WM_MOUSEMOVE: if(!m_bMouseOver && PtInBB(MousePos) && GetVisible()){ OnMouseEnter(); }if(m_bMouseOver && !PtInBB(MousePos)){ OnMouseLeave(); } if(m_bButtonDown && m_bMouseOver){ Scroll((MousePos.x-m_mouseStart.x)*(m_maxValue/(m_maxBarWidth-m_barWidth))); m_mouseStart=MousePos; } //if(Parent && ((CGUIWindow*)Parent)->GetFocusElement()==this) //return true; break; case WM_LBUTTONDOWN: if(m_bMouseOver){ if(GetFocus() || RequestFocus()){ m_bButtonDown=true; m_mouseStart=MousePos; } return true; } break; case WM_LBUTTONUP: if(m_bButtonDown && m_bMouseOver){ OnHotkey(); m_bButtonDown=false; return true; } m_bButtonDown=false; break; } if(m_bMouseOver) return true; return false; }
void UIBase::Input(){ int key = InputManager::GetInstance().GetMouseMousePressKey(); Point mpos = InputManager::GetInstance().GetMouse(); if (IsInside(mpos.x,mpos.y)){ if (key != 0 && OnMousePress){ OnMousePress(this,key,mpos); } key = InputManager::GetInstance().GetMouseMouseReleaseKey(); if (key != 0 && OnMouseRelease){ OnMouseRelease(this,key,mpos); } if (!MouseInside){ if (OnMouseEnter){ OnMouseEnter(this,mpos); } MouseInside = true; } }else{ if (MouseInside){ if (OnMouseLeave){ OnMouseLeave(this,mpos); } MouseInside = false; } } key = InputManager::GetInstance().IsAnyKeyPressed(); if (key != -1 && OnKeyPress){ OnKeyPress(this,key); } /*for (unsigned i = 0; i < Components.size(); ++i) { if (!Components[i]->IsDead()){ Components[i]->Input(); } }*/ }
void MenuItem::MouseEntered(const MouseEvent& lEvent) { if(!IsParentMenuOpen()) { return; } Menu* lpParentMenu = (Menu* )GetParent(); // Make sure that we are inside the bounds of the parent menu if(lpParentMenu->GetPullDownMenuParent() != NULL) { int lTextHeight = m_pRenderer->GetFreeTypeTextHeight(lpParentMenu->GetPullDownMenuParent()->GetGUIFont(), "%s", lpParentMenu->GetMenuTitle().c_str()); int lMenuHeight = lTextHeight + (lpParentMenu->GetMenuItemSpacer() * 2); int lFullMenuDisplayHeight = lpParentMenu->GetPullDownMenuParent()->GetMaxNumItemsDisplayed() * lMenuHeight; Point location = lpParentMenu->GetPullDownMenuParent()->GetLocation(); for(Component* parent = lpParentMenu->GetPullDownMenuParent()->GetParent(); parent != 0;) { Point parentLocation = parent->GetLocation(); location.m_x += parentLocation.m_x; location.m_y += parentLocation.m_y; parent = parent->GetParent(); } int lMenuX = location.m_x; int lMenuY = location.m_y - lFullMenuDisplayHeight; int lMenuWidth = lpParentMenu->GetBiggestWidth()+ (lpParentMenu->GetMenuItemSpacer() * 2); if(lEvent.GetX() > lMenuX && lEvent.GetX() <= lMenuX+lMenuWidth && lEvent.GetY() > lMenuY && lEvent.GetY() <= lMenuY+lFullMenuDisplayHeight) { SetHover(true); OnMouseEnter(); } } }
void wxToolBar::OnMouseEvent( wxMouseEvent& rEvent ) { POINTL vPoint; HWND hWnd; wxCoord vX; wxCoord vY; HPOINTER hPtr = ::WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE); ::WinSetPointer(HWND_DESKTOP, hPtr); ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); hWnd = ::WinWindowFromPoint(HWND_DESKTOP, &vPoint, TRUE); if (hWnd != (HWND)GetHwnd()) { m_vToolTimer.Stop(); return; } rEvent.GetPosition(&vX, &vY); wxToolBarTool* pTool = (wxToolBarTool *)FindToolForPosition( vX ,vY ); if (rEvent.LeftDown()) { CaptureMouse(); } if (rEvent.LeftUp()) { ReleaseMouse(); } if (!pTool) { m_vToolTimer.Stop(); if (m_nCurrentTool > -1) { if (rEvent.LeftIsDown()) SpringUpButton(m_nCurrentTool); pTool = (wxToolBarTool *)FindById(m_nCurrentTool); if (pTool && !pTool->IsToggled()) { RaiseTool( pTool, FALSE ); } m_nCurrentTool = -1; OnMouseEnter(-1); } return; } if (!rEvent.IsButton()) { if (pTool->GetId() != m_nCurrentTool) { // // If the left button is kept down and moved over buttons, // press those buttons. // if (rEvent.LeftIsDown() && pTool->IsEnabled()) { SpringUpButton(m_nCurrentTool); if (pTool->CanBeToggled()) { pTool->Toggle(); } DrawTool(pTool); } wxToolBarTool* pOldTool = (wxToolBarTool*)FindById(m_nCurrentTool); if (pOldTool && !pTool->IsToggled()) RaiseTool( pOldTool, FALSE ); m_nCurrentTool = pTool->GetId(); OnMouseEnter(m_nCurrentTool); if (!pTool->GetShortHelp().empty()) { if (m_pToolTip) delete m_pToolTip; m_pToolTip = new wxToolTip(pTool->GetShortHelp()); m_vXMouse = (wxCoord)vPoint.x; m_vYMouse = (wxCoord)vPoint.y; m_vToolTimer.Start(1000L, TRUE); } if (!pTool->IsToggled()) RaiseTool(pTool); } return; } // Left button pressed. if (rEvent.LeftDown() && pTool->IsEnabled()) { if (pTool->CanBeToggled()) { pTool->Toggle(); } DrawTool(pTool); } else if (rEvent.RightDown()) { OnRightClick( pTool->GetId() ,vX ,vY ); } // // Left Button Released. Only this action confirms selection. // If the button is enabled and it is not a toggle tool and it is // in the pressed state, then raise the button and call OnLeftClick. // if (rEvent.LeftUp() && pTool->IsEnabled() ) { // // Pass the OnLeftClick event to tool // if (!OnLeftClick( pTool->GetId() ,pTool->IsToggled()) && pTool->CanBeToggled()) { // // If it was a toggle, and OnLeftClick says No Toggle allowed, // then change it back // pTool->Toggle(); } DrawTool(pTool); } } // end of wxToolBar::OnMouseEvent
void Widget::HandleEvent( const sf::Event& event ) { if( !IsVisible() ) { return; } // Set widget active in context. Context::Get().SetActiveWidget( shared_from_this() ); Container::Ptr parent( m_parent.lock() ); switch( event.Type ) { case sf::Event::MouseMoved: // Check if pointer inside of widget's allocation. if( GetAllocation().Contains( static_cast<float>( event.MouseMove.X ), static_cast<float>( event.MouseMove.Y ) ) ) { // Check for enter event. if( m_mouse_in == false ) { m_mouse_in = true; OnMouseEnter(); HandleMouseEnter( event.MouseMove.X, event.MouseMove.Y ); } OnMouseMove(); } else if( m_mouse_in == true ) { // Check for leave event. m_mouse_in = false; OnMouseLeave(); HandleMouseLeave( event.MouseMove.X, event.MouseMove.Y ); } HandleMouseMoveEvent( event.MouseMove.X, event.MouseMove.Y ); break; case sf::Event::MouseButtonPressed: // If a mouse button has already been pressed for this widget, drop further // presses. This maybe needs changing, but up to now, I can't think of any // cases where it would be useful to have such a functionality. if( m_mouse_button_down == -1 ) { if( m_mouse_in ) { m_mouse_button_down = event.MouseButton.Button; HandleMouseButtonEvent( event.MouseButton.Button, true, event.MouseButton.X, event.MouseButton.Y ); OnMouseButtonPress(); } } break; case sf::Event::MouseButtonReleased: // Only process when mouse button has been clicked inside the widget before. if( m_mouse_button_down == event.MouseButton.Button ) { m_mouse_button_down = -1; // When released inside the widget, the event can be considered a click. if( m_mouse_in ) { HandleMouseClick( event.MouseButton.Button, event.MouseButton.X, event.MouseButton.Y ); } OnMouseButtonRelease(); } HandleMouseButtonEvent( event.MouseButton.Button, false, event.MouseButton.X, event.MouseButton.Y ); break; case sf::Event::KeyPressed: if( GetState() == Active ) { // TODO: Delegate event too when widget's not active? HandleKeyEvent( event.Key.Code, true ); OnKeyPress(); } break; case sf::Event::KeyReleased: if( GetState() == Active ) { // TODO: Delegate event too when widget's not active? HandleKeyEvent( event.Key.Code, false ); OnKeyRelease(); } break; case sf::Event::TextEntered: if( GetState() == Active ) { // TODO: Delegate event too when widget's not active? HandleTextEvent( event.Text.Unicode ); OnText(); } break; default: break; } }
void GUIControl::Process() { __super::Process(); if(IsVisible() && IsEnabled()) { if(PointInBox(mouseX, mouseY, GetX(), GetY(), GetWidth(), GetHeight())) { int cursor = GetLastCursorPos(); SetLastCursorPos(1); // mouse is in // here // 0 - init // 1 - mouse was IN control // 2 - mouse was OUT control if(cursor == 0 || cursor == 2) { OnMouseEnter(); } else { OnMouseMove(); } if(mouse[0] || mouse[1]) { if(GetLastPressState() == 0) { OnMouseDown(); if(mouse[0]) SetLastPressState(1); else if(mouse[1]) SetLastPressState(2); } } else { int press_state = GetLastPressState(); SetLastPressState(0); // here // 0 - init // 1 - left mouse down // 2 - right mouse down // 3 - all up if(press_state == 1) { OnLeftClick(); OnMouseUp(); } else if(press_state == 2) { OnRightClick(); OnMouseUp(); } } } else { int cursor = GetLastCursorPos(); SetLastCursorPos(2); // mouse is out if(cursor == 1) { OnMouseLeave(); SetLastPressState(0); } } // TODO: // fix it somehow :( if(IsFocused()) { static UCHAR count = 0; int delay = 0; for(UCHAR i = 0; i < 255; i++) { if(GetAsyncKeyState(i) & 0x8000) { count++; static int prev; count == 1 ? delay = KEY_FIRST_DELAY : delay = KEY_DELAY; if(current_time - prev >= delay) { if(i != VK_SHIFT) { OnKeyDown(i); prev = current_time; } } } } } } }
void TitleBar::MouseEntered(const MouseEvent& lEvent) { m_bFirstOutsideDrag = false; OnMouseEnter(); }
void UIElement::CheckInput() { if (interactive) { int mouseX, mouseY; App->input->GetMousePosition(mouseX, mouseY); int elementX = GetWorldRect().x; int elementY = GetWorldRect().y; if (App->gui->debugMode) { int colX = GetWorldRect().x; int colY = GetWorldRect().y; App->render->DrawQuad(SDL_Rect{ colX - App->render->camera.x, colY - App->render->camera.y, collider.w, collider.h }, 255, 0, 0, 50, false); } if (mouseX > elementX && mouseX < elementX + collider.w && mouseY >elementY && mouseY < elementY + collider.h) { if (!mouseWasIn) { //LOG("%s - Mouse Enter", name.GetString()); mouseWasIn = true; App->gui->SetHovering(this); OnMouseEnter(); if (listener) { listener->OnGUI(MOUSE_ENTER, this); } App->gui->inputRecieved = true; } if (App->input->GetMouseButtonDown(SDL_BUTTON_LEFT) == KEY_DOWN) { //LOG("%s - Mouse Down", name.GetString()); mouseWasClicked = true; OnMouseDown(); if (listener) { listener->OnGUI(MOUSE_DOWN, this); } App->gui->inputRecieved = true; App->gui->SetFocus(this); } else if (App->input->GetMouseButtonDown(SDL_BUTTON_LEFT) == KEY_UP) { if (mouseWasClicked) { //LOG("%s - Mouse Up", name.GetString()); mouseWasClicked = false; OnMouseUp(); if (listener) { listener->OnGUI(MOUSE_UP, this); } App->gui->inputRecieved = true; } else if (App->gui->GetFocus()) { if(App->gui->GetFocus()->mouseWasClicked) { App->gui->GetFocus()->OnMouseUp(); } } } } else { // if (mouseWasClicked) // mouseWasClicked = false; if (mouseWasIn) { //LOG("%s - Mouse Exit", name.GetString()); mouseWasIn = false; OnMouseExit(); App->gui->SetHovering(NULL); if (listener) { listener->OnGUI(MOUSE_EXIT, this); } App->gui->inputRecieved = true; } } if (App->gui->GetFocus() == this) { if (App->input->GetKey(SDL_SCANCODE_RETURN) == KEY_DOWN) { //LOG("%s - Return down", name.GetString()); if (listener) { listener->OnGUI(RETURN_DOWN, this); } } } } }
void UUserWidget::NativeOnMouseEnter( const FGeometry& InGeometry, const FPointerEvent& InMouseEvent ) { OnMouseEnter( InGeometry, InMouseEvent ); }
void wxToolBar::OnKillFocus( wxFocusEvent& WXUNUSED(rEvent) ) { OnMouseEnter(m_nPressedTool = m_nCurrentTool = -1); } // end of wxToolBar::OnKillFocus
void Control::NotificationMouseEnter() { OnMouseEnter(); }