GuiMLTextCtrl
A text control that uses the Gui Markup Language ('ML') tags to dynamically change the text.
Text
int
The number of blank pixels to place between each line.
bool
If true, the control will allow characters to have unique colors.
int
Maximum number of characters that the control will display.
If the text will not fit in the control, the deniedSound is played.
caseString
Text to display in this control.
bool
If true, the mouse cursor will turn into a hand cursor while over a link in the text.
Callbacks
Public Functions
void
addText(string text, bool reformat)
Appends the text in the control with additional text. Also .
void
Forces the text control to reflow the text after new text is added, possibly resizing the control.
string
getText()
Returns the text from the control, including TorqueML characters.
void
Scroll to the bottom of the text.
void
scrollToTag(int tagID)
Scroll down to a specified tag.
void
Scroll to the top of the text.
void
setAlpha(float alphaVal)
Sets the alpha value of the control.
bool
setCursorPosition(int newPos)
Change the text cursor's position to a new defined offset within the text in the control.
void
setText(string text)
Set the text contained in the control.
Detailed Description
A text control that uses the Gui Markup Language ('ML') tags to dynamically change the text.
Example of dynamic changes include colors, styles, and/or hyperlinks. These changes can occur without having to use separate text controls with separate text profiles.
new GuiMLTextCtrl(CenterPrintText) { lineSpacing = "2"; allowColorChars = "0"; maxChars = "-1"; deniedSound = "DeniedSoundProfile"; text = "The Text for This Control."; useURLMouseCursor = "true"; //Properties not specific to this control have been omitted from this example. };
Text
int lineSpacing
The number of blank pixels to place between each line.
bool allowColorChars
If true, the control will allow characters to have unique colors.
int maxChars
Maximum number of characters that the control will display.
SFXTrack deniedSound
If the text will not fit in the control, the deniedSound is played.
caseString text
Text to display in this control.
bool useURLMouseCursor
If true, the mouse cursor will turn into a hand cursor while over a link in the text.
This is dependant on the markup language used by the GuiMLTextCtrl
Callbacks
onURL(string url)
Called whenever a URL was clicked on within the control.
Parameters:
url | The URL address that was clicked on. // A URL address was clicked on in the control, causing the callback to occur. GuiMLTextCtrl::onUrl(%this,%url) { // Code to run whenever a URL was clicked on } |
onResize(int width, int maxY)
Called whenever the control size changes.
Parameters:
width | The new width value for the control |
maxY | The current maximum allowed Y value for the control |
// Control size changed, causing the callback to occur. GuiMLTextCtrl::onResize(%this,%width,%maxY) { // Code to call when the control size changes }
Public Functions
addText(string text, bool reformat)
Appends the text in the control with additional text. Also .
Parameters:
text | New text to append to the existing text. |
reformat | If true, the control will also be visually reset (defaults to true). // Define new text to add %text = "New Text to Add"; // Set reformat boolean %reformat = "true"; // Inform the control to add the new text %thisGuiMLTextCtrl.addText(%text,%reformat); |
forceReflow()
Forces the text control to reflow the text after new text is added, possibly resizing the control.
// Define new text to add %newText = "BACON!"; // Add the new text to the control %thisGuiMLTextCtrl.addText(%newText); // Inform the GuiMLTextCtrl object to force a reflow to ensure the added text fits properly. %thisGuiMLTextCtrl.forceReflow();
getText()
Returns the text from the control, including TorqueML characters.
// Get the text displayed in the control %controlText = %thisGuiMLTextCtrl.getText();
Text string displayed in the control, including any TorqueML characters.
scrollToBottom()
Scroll to the bottom of the text.
// Inform GuiMLTextCtrl object to scroll to its bottom %thisGuiMLTextCtrl.scrollToBottom();
scrollToTag(int tagID)
Scroll down to a specified tag.
Detailed description
Parameters:
tagID | TagID to scroll the control to // Define the TagID we want to scroll the control to %tagId = "4"; // Inform the GuiMLTextCtrl to scroll to the defined TagID %thisGuiMLTextCtrl.scrollToTag(%tagId); |
scrollToTop()
Scroll to the top of the text.
// Inform GuiMLTextCtrl object to scroll to its top %thisGuiMLTextCtrl.scrollToTop();
setAlpha(float alphaVal)
Sets the alpha value of the control.
Parameters:
alphaVal | n - 1.0 floating value for the alpha // Define the alphe value %alphaVal = "0.5"; // Inform the control to update its alpha value. %thisGuiMLTextCtrl.setAlpha(%alphaVal); |
setCursorPosition(int newPos)
Change the text cursor's position to a new defined offset within the text in the control.
Parameters:
newPos | Offset to place cursor. // Define cursor offset position %position = "23"; // Inform the GuiMLTextCtrl object to move the cursor to the new position. %thisGuiMLTextCtrl.setCursorPosition(%position); |
Returns true if the cursor position moved, or false if the position was not changed.
setText(string text)
Set the text contained in the control.
Parameters:
text | The text to display in the control. // Define the text to display %text = "Nifty Control Text"; // Set the text displayed within the control %thisGuiMLTextCtrl.setText(%text); |