SKIN:PaintTextEntry
SKIN:PaintTextEntry
This function is used to define how a DTextEntry
is drawn within a Derma skin. It is commonly used to render the background, text, text selection, and caret (cursor) using the Panel:DrawTextEntryText
method.
<a class="realm_icon" href="/gmod/States" title="This function is available in client and menu state(s)"> </a>
Description
Used to draw the text in a [DTextEntry
](DTextEntry) within a Derma skin. This is usually called inside the [SKIN:PaintTextEntry
](SKIN:PaintTextEntry) skin hook to render custom styles.
Note: Will silently fail if any of the arguments to
DrawTextEntryText
are not given.
Note: This is a rendering function that requires a 2D rendering context.
This means it will only work inside [2D Rendering Hooks](2d_Rendering_Hooks) such asPaint
,PaintOver
, etc.
Arguments
[
table
](table)textCol
The color of the main text.[
table
](table)highlightCol
The color used for highlighting selected text.[
table
](table)cursorCol
The color of the text caret (cursor).
Example
The following example shows how the default GMod skin uses SKIN:PaintTextEntry
to render the background and text of a DTextEntry
:
```lua function SKIN:PaintTextEntry(panel, w, h)
if (panel.m_bBackground) then
if (panel:GetDisabled()) then self.tex.TextBox_Disabled(0, 0, w, h) elseif (panel:HasFocus()) then self.tex.TextBox_Focus(0, 0, w, h) else self.tex.TextBox(0, 0, w, h) end
end
panel:DrawTextEntryText( panel.m_colText, -- Text color panel.m_colHighlight, -- Highlight color panel.m_colCursor -- Cursor color )
end