Files
Basalt/docs/objects/Textfield/addKeywords.md
Robert Jelic bb1b1beb79 Basalt 1.7 Update
- 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
2023-04-30 17:05:34 +02:00

1.3 KiB

addKeywords

Description

Adds keywords for special coloring in a Textfield object. This allows you to highlight specific words with a chosen color.

Parameteres

  1. number|color color - The color you want to apply to the keywords
  2. table keywords - A list of keywords that should be colored, for example: {"if", "else", "then", "while", "do", "hello"}

Returns

  1. object The object in use

Usage

  • Changes the color of specific words to purple in a Textfield object:
local basalt = require("basalt")

local mainFrame = basalt.createFrame()
local aTextfield = mainFrame:addTextfield()

aTextfield:addKeywords(colors.purple, {"if", "else", "then", "while", "do", "hello"})

basalt.autoUpdate()

In this example, a Textfield object is created and added to the mainFrame. The addKeywords method is called to add a list of keywords to be highlighted in purple color. The specified keywords are "if", "else", "then", "while", "do", and "hello".

<textfield>
    <keywords>
        <purple>
            <keyword>if</keyword>
            <keyword>else</keyword>
            <keyword>then</keyword>
            <keyword>while</keyword>
            <keyword>do</keyword>
            <keyword>hello</keyword>
        </purple>
    </keywords>
</textfield>