DgsEditSetTextFilter: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ This function sets the white list of edit text. White List in edit means every character of the text should meet the requirement of the white lis...")
 
m (Thisdp moved page DgsEditSetWhiteList to DgsEditSetTextFilter)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
This function sets the white list of edit text. White List in edit means every character of the text should meet the requirement of the white list, or the characters will be cut.
This function sets the text filter of edit text. Text Filter in edit means every character of the text should meet the requirement of the filter, or the characters will be cut.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsEditSetWhiteList( element edit, string whitelist )
bool dgsEditSetTextFilter( element edit, string filter )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''edit:''' the dgs edit you want to set.
*'''edit:''' the dgs edit you want to set.
*'''whitelist:''' the pattern (regular expression).
*'''filter:''' the pattern (refer to lua pattern).


===Returns===
===Returns===
Line 20: Line 20:


local edit = DGS:dgsCreateEdit(0.3,0.3,0.2,0.05,"",true)
local edit = DGS:dgsCreateEdit(0.3,0.3,0.2,0.05,"",true)
DGS:dgsEditSetWhiteList(edit ,"[^a-zA-Z0-9$]") --This regular expression set a restrict that the character of text allowed is from "a" to "z", "A" to "Z" and 0 to 9
DGS:dgsEditSetTextFilter(edit ,"[^a-zA-Z0-9$]") --This regular expression set a restrict that the character of text allowed is from "a" to "z", "A" to "Z" and 0 to 9


</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 15:33, 9 July 2022

This function sets the text filter of edit text. Text Filter in edit means every character of the text should meet the requirement of the filter, or the characters will be cut.

Syntax

bool dgsEditSetTextFilter( element edit, string filter )

Required Arguments

  • edit: the dgs edit you want to set.
  • filter: the pattern (refer to lua pattern).

Returns

Returns true if succeeded, false otherwise.

Example

DGS = exports.dgs

local edit = DGS:dgsCreateEdit(0.3,0.3,0.2,0.05,"",true)
DGS:dgsEditSetTextFilter(edit ,"[^a-zA-Z0-9$]") --This regular expression set a restrict that the character of text allowed is from "a" to "z", "A" to "Z" and 0 to 9

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips