VGUI Tooltip: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 6: Line 6:


== Known Problems with Tooltips ==
== Known Problems with Tooltips ==
= SetText =
Calling Tooltip::SetText on a tooltip when a tooltip window is visible changes the text for the visible tooltip window. Make sure that you check to make sure no tooltip windows are currently open before calling Tooltip::SetText.
Calling Tooltip::SetText on a tooltip when a tooltip window is visible changes the text for the visible tooltip window. Make sure that you check to make sure no tooltip windows are currently open before calling Tooltip::SetText.


Line 39: Line 41:


I'm not sure why, but as you can see in the code above, towards the end of the function Tooltip::SetText, it changes the text of the active tooltip window. Valve needs to remove this from their code to fix this bug.
I'm not sure why, but as you can see in the code above, towards the end of the function Tooltip::SetText, it changes the text of the active tooltip window. Valve needs to remove this from their code to fix this bug.
= Screenshots =
It seems that while the tooltip window is visible, the concommand screenshot does not work.
[[Category:VGUI Controls]]
[[Category:VGUI Controls]]

Revision as of 12:59, 6 June 2009

A tooltip is a vgui2 element defined in the vgui_controls library, in the file Tooltip.cpp.

Tooltip.jpg

Example Usage

Known Problems with Tooltips

SetText

Calling Tooltip::SetText on a tooltip when a tooltip window is visible changes the text for the visible tooltip window. Make sure that you check to make sure no tooltip windows are currently open before calling Tooltip::SetText.

void Tooltip::SetText(const char *text)
{
	_isDirty = true;

	if (!text)
	{
		text = "";
	}

	if (m_Text.Size() > 0)
	{
		m_Text.RemoveAll();
	}

	for (unsigned int i = 0; i < strlen(text); i++)
	{
		m_Text.AddToTail(text[i]);
	}
	m_Text.AddToTail('\0');
	
	if (s_TooltipWindow.Get())
	{
		s_TooltipWindow->SetText(m_Text.Base());
	}
}

The code above was taken from line 89 of tooltip.cpp.

Valve uses a static handler for the current displayed tooltip window (declared on line 28 of tooltip.cpp), static vgui::DHANDLE< TextEntry > s_TooltipWindow;.

I'm not sure why, but as you can see in the code above, towards the end of the function Tooltip::SetText, it changes the text of the active tooltip window. Valve needs to remove this from their code to fix this bug.

Screenshots

It seems that while the tooltip window is visible, the concommand screenshot does not work.