Fix crash on VGUI menu bar button cursor entrance

This commit is contained in:
RGBACatlord 2025-03-18 12:12:50 +13:00 committed by EricS-Valve
parent 6956e9680e
commit 48809cb86c
3 changed files with 16 additions and 2 deletions

View File

@ -41,7 +41,11 @@ protected:
virtual void PerformLayout();
virtual void Paint();
MESSAGE_FUNC( OnMenuClose, "MenuClose" );
MESSAGE_FUNC_INT( OnCursorEnteredMenuButton, "CursorEnteredMenuButton", VPanel);
#ifdef PLATFORM_64BITS
MESSAGE_FUNC_PTR( OnCursorEnteredMenuButton, "CursorEnteredMenuButton", VPanel );
#else
MESSAGE_FUNC_INT( OnCursorEnteredMenuButton, "CursorEnteredMenuButton", VPanel );
#endif
private:
CUtlVector<MenuButton *> m_pMenuButtons;

View File

@ -221,9 +221,15 @@ void MenuBar::OnMenuClose()
//-----------------------------------------------------------------------------
// Purpose: Message map
//-----------------------------------------------------------------------------
void MenuBar::OnCursorEnteredMenuButton(int VPanel)
#ifdef PLATFORM_64BITS
void MenuBar::OnCursorEnteredMenuButton(vgui::Panel* VPanel)
{
VPANEL menuButton = (VPANEL)VPanel;
#else
void Menu::OnCursorEnteredMenuItem(int VPanel)
{
VPANEL menuButton = (VPANEL)VPanel;
#endif
// see if we had a menu open
for ( int i = 0; i < m_pMenuButtons.Count(); i++)
{

View File

@ -238,7 +238,11 @@ void MenuButton::OnCursorEntered()
// forward the message on to the parent of this menu.
KeyValues *msg = new KeyValues ("CursorEnteredMenuButton");
// tell the parent this menuitem is the one that was entered so it can open the menu if it wants
#ifdef PLATFORM_64BITS
msg->SetPtr("VPanel", (void*)GetVPanel());
#else
msg->SetInt("VPanel", GetVPanel());
#endif
ivgui()->PostMessage(GetVParent(), msg, NULL);
}