Nifty TextField - how to change color?

How do I change the background color (which defaults to red) in the Nifty-GUI textfield control element? backgroundColor and color don’t seem to have an effect on the textfield. Only selectioncolor which changes the text’s color.


As far as I know, you’ll need to create a style document and then include it in your main document.

Example style document: (a modification of the nifty textfield black-style)


<?xml version=“1.0” encoding=“UTF-8”?>

<nifty-styles xmlns=“” xmlns:xsi=“” xsi:schemaLocation=“”>

<style id=“nifty-textfield#field”>

<attributes childLayout=“center” visibleToMouse=“true” childClip=“true” backgroundColor="#666f" padding=“0px,2px” />


<onActive name=“border” color="#222f" post=“true” inset=“1px” />

<!-- This should change the regular colour -->

<onFocus name=“colorBar” color="#800f" post=“true” inset=“1px” />

<!-- Rollover effect -->

<onHover name=“changeMouseCursor” id=“textFieldCursor” />

<onHover name=“border” color="#822f" post=“true” />

<!-- These two change the overlay when the field is disabled -->

<onEnabled name=“renderQuad” startColor="#2228" endColor="#2220" post=“true” length=“150” />

<onDisabled name=“renderQuad” startColor="#2220" endColor="#2228" post=“true” length=“150” />





Then below your [xml]<useStyles filename=“nifty-default-styles.xml” />[/xml] line, add:

[xml]<useStyles filename=“Interface/path-to-document/textfield-style-document.xml” />[/xml]

Hope that helps a bit (and hope it works too, I didn’t try it out just then)

(Edit: the link finder in this text editor must execute before the xml formatter…)