Skip to content

Commit

Permalink
Clean up mouse centering code
Browse files Browse the repository at this point in the history
  • Loading branch information
TomyLobo committed Jun 8, 2016
1 parent 0a8c31a commit c151c8a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions mp/src/game/client/hud_basechat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1199,10 +1199,22 @@ void CBaseHudChat::StartMessageMode( int iMessageModeType )
m_pChatInput->SetPaintBorderEnabled( true );
m_pChatInput->SetMouseInputEnabled( true );

//Place the mouse cursor near the text so people notice it.
int x, y, w, h;
GetBounds( x, y, w, h );
vgui::input()->SetCursorPos( x + ( w/2), y + (h/2) );
// Pick a target panel to place the mouse cursor on so people notice it.
Panel *pTargetPanel = this;

// Retrieve its size
int w, h;
pTargetPanel->GetSize(w, h);

// Center the cursor onto it
int cx = w / 2;
int cy = h / 2;

// Translate to screen coordinates
pTargetPanel->LocalToScreen(cx, cy);

// Set cursor position
vgui::input()->SetCursorPos(cx, cy);

m_flHistoryFadeTime = gpGlobals->curtime + CHAT_HISTORY_FADE_TIME;

Expand Down

0 comments on commit c151c8a

Please sign in to comment.