Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_LimitTextLength.c
Go to the documentation of this file.
1// Generic component that limits TextWidget or RichTextWidget content length
3{
4 [Attribute("1000")]
5 protected int m_iMaxTextLenght;
6
7 //------------------------------------------------------------------------------------------------
8 override void HandlerAttached(Widget w)
9 {
10 LimitText(w);
11 }
12
13 //------------------------------------------------------------------------------------------------
14 override bool OnUpdate(Widget w)
15 {
16 GetGame().GetCallqueue().CallLater(LimitText, 0, false, w);
17
18 return true;
19 }
20
21 //-----------------------------------------------------------------------------------
22 protected void LimitText(Widget w)
23 {
24 TextWidget textWidget = TextWidget.Cast(w);
25
26 if (!textWidget)
27 return;
28
29 string text = textWidget.GetText();
30
31 // Edit text if it's too long
32 if (text.Length() > m_iMaxTextLenght)
33 {
34 text = text.Substring(0, m_iMaxTextLenght);
35 text += "...";
36 }
37
38 textWidget.SetText(text);
39 }
40};
ArmaReforgerScripted GetGame()
Definition game.c:1398
override void HandlerAttached(Widget w)
override bool OnUpdate(Widget w)
SCR_FieldOfViewSettings Attribute