- New Objects (Flexbox, Graph, Treeview) - Pluginsystem to add/remove functionality - Reworked the entire Object system, instead of one big Object Class we have multiple classes: Object, VisualObject, ChangeableObject - Instead of one big Frame Class we have multiple Frame Classes: BaseFrame, Frame, MovableFrame, ScrollableFrame, MonitorFrame, Flexbox - Removed the Animation Object, and added a animation plugin instead - Removed the Graphic Object and merged it's functionality with the image object - Updated currently existing objects
1.3 KiB
1.3 KiB
addRule
Description
Adds a new rule for special coloring in a Textfield object. This allows you to apply a specific color and/or background color to text matching a provided pattern.
Parameteres
stringpattern - A Lua pattern for matching the text you want to color. You can find more information about Lua patterns here.number|colortextColor - The color you want to apply to the text matching the patternnumber|colorbackgroundColor - (optional) The background color you want to apply to the text matching the pattern
Returns
objectThe object in use
Usage
- Changes the color of all numbers in a Textfield object
local basalt = require("basalt")
local mainFrame = basalt.createFrame()
local aTextfield = mainFrame:addTextfield()
aTextfield:addRule("%d", colors.lightBlue)
basalt.autoUpdate()
In this example, a Textfield object is created and added to the mainFrame. The addRule method is called to add a rule that highlights all numbers with a light blue color. The pattern used for matching numbers is %d.
<textfield>
<rules>
<rule>
<pattern>%d</pattern>
<fg>lightBlue</fg>
</rule>
</rules>
</textfield>