DialogControls-EditBox: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(added some missing properties)
Line 1: Line 1:
'''TokenNames common to most controls, such as x,y,w,h,text,idc... are not listed here. '''
'''TokenNames common to most controls, such as x,y,w,h,text,idc... are not listed here. '''
===CT_EDIT=2===
===CT_EDIT=2===
A text box allows the user to either enter text himself, or to select and copy its content.<br>
A text box, which allows the user to either enter text himself or to select and copy its content.
*Note that it is illogical to create an edit box with NO valid idc. The engine is quite capable of crashing if it has nowhere to send the text to (idc=-1) and Arrowhead configs specifically prevent this.
**If you wish to have the editbox STYLE, use CT_STATIC with ST_FRAME


{| border="1" cellpadding="3" cellspacing="0" |
{| border="1" cellpadding="3" cellspacing="0" |
Line 14: Line 12:
| '''autocomplete'''
| '''autocomplete'''
| string  
| string  
| "", or "scripting" (entered text will automatically be completed with matching command) or "general"
| "" or "scripting" (entered text will automatically be completed with matching script command)
|-
|-
| '''htmlControl'''
| '''canModify'''
| boolean
| boolean
| if used together with style=ST_MULTI, allows multi-line editable text fields.
| Optional. Default: true. When false, only LEFT/RIGHT/HOME/END, CTRL + C, SHIFT + LEFT/RIGHT/HOME/END keys are allowed
|-
|-
| '''lineSpacing'''
| '''maxChars'''
| float
| integer
| line spacing. Required, if the style was set to <tt>ST_MULTI</tt>.
| Optional. Default: 2147483647. The limit for how many characters could be displayed or entered, counting new line characters too
|-
| '''forceDrawCaret'''
| boolean
| Optional. Default: false. When true, the caret will be drawn even when control has no focus or is disabled
|-
|-
| '''colorSelection'''
| '''colorSelection'''
| color
| color
|  
| The text selection highlight color
|-
| '''colorText'''
| color
| The color of the text, caret and border
|-
| '''colorDisabled'''
| color
| The color of the text, caret and border when control is disabled
|-
| '''colorBackground'''
| color
| The color of the edit box background
|-
| '''font'''
| string
| Font name
|-
|-
| '''size'''
| '''sizeEx'''
| float
| float
| possibly a typo, perhaps irrelevant xbox property
| Font size
|-
|-
|}<br clear="all">
|}<br clear="all">


* '''Example:'''
* '''Example:'''
<code><nowiki>
<syntaxhighlight lang=cpp>
class RscEdit
class MyEdit
{
{
access = 0;
idc = -1;
type = CT_EDIT;
type = 2;
style = ST_LEFT+ST_FRAME;
style = "16 + 512"; // multi line + no border
x = 0;
x = 0;
y = 0;
y = 0;
h = 0.04;
h = 0.2;
w = 0.2;
w = 1;
colorBackground[] = {0,0,0,0};
font = "PuristaMedium";
colorText[] = {1,1,1,1};
sizeEx = 0.04;
colorSelection[] = {1,1,1,0.25};
autocomplete = "";
font = "TahomaB";
canModify = true;
sizeEx = 0.04;
maxChars = 100;
autocomplete = "";
forceDrawCaret = false;
text = "";
colorSelection[] = {0,1,0,1};
size = 0.2;
colorText[] = {0,0,1,1};
shadow = 0;
colorDisabled[] = {1,0,0,1};
colorBackground[] = {0,0,0,0.5};  
text = __EVAL("Line 1" + endl + "Line 2" + endl + "Line 3"); // how to output multiline
};
};
class dialog
 
class MyDialog
{
{
class controls
idd = -1;
{
 
  class Value: RscEdit
class controls
  {
{
  idc = 120; // otherwise there's not much point
class Enabled: MyEdit
  x = 0.3025;
{
  y = 0.34;
style = 16;
  text = "whatever";
colorBackground[] = {0,0,0,0};
  autocomplete = "scripting";
};
  };
 
};
class Disabled: MyEdit
};
{
</nowiki></code>
onLoad = "_this select 0 ctrlEnable false";
y = 0.3;
maxChars = 18;
forceDrawCaret = true;
};
};
};</syntaxhighlight>
<code>[[createDialog]] "MyDialog";</code>
[[Category: Dialogs]]
[[Category: Dialogs]]

Revision as of 01:27, 9 July 2017

TokenNames common to most controls, such as x,y,w,h,text,idc... are not listed here.

CT_EDIT=2

A text box, which allows the user to either enter text himself or to select and copy its content.

Properties
Name Type Remark
autocomplete string "" or "scripting" (entered text will automatically be completed with matching script command)
canModify boolean Optional. Default: true. When false, only LEFT/RIGHT/HOME/END, CTRL + C, SHIFT + LEFT/RIGHT/HOME/END keys are allowed
maxChars integer Optional. Default: 2147483647. The limit for how many characters could be displayed or entered, counting new line characters too
forceDrawCaret boolean Optional. Default: false. When true, the caret will be drawn even when control has no focus or is disabled
colorSelection color The text selection highlight color
colorText color The color of the text, caret and border
colorDisabled color The color of the text, caret and border when control is disabled
colorBackground color The color of the edit box background
font string Font name
sizeEx float Font size


  • Example:
class MyEdit
{
	idc = -1;
	type = 2;
	style = "16 + 512"; // multi line + no border
	x = 0;
	y = 0;
	h = 0.2;
	w = 1;
	font = "PuristaMedium";
	sizeEx = 0.04;
	autocomplete = "";
	canModify = true; 
	maxChars = 100; 
	forceDrawCaret = false;
	colorSelection[] = {0,1,0,1};
	colorText[] = {0,0,1,1};
	colorDisabled[] = {1,0,0,1}; 
	colorBackground[] = {0,0,0,0.5}; 
	text = __EVAL("Line 1" + endl + "Line 2" + endl + "Line 3"); // how to output multiline
};

class MyDialog
{
	idd = -1;

	class controls
	{
		class Enabled: MyEdit
		{
			style = 16;
			colorBackground[] = {0,0,0,0};
		};

		class Disabled: MyEdit
		{
			onLoad = "_this select 0 ctrlEnable false";
			y = 0.3;
			maxChars = 18;
			forceDrawCaret = true;
		};
	};
};

createDialog "MyDialog";