Jump to content
Sign in to follow this  
Icaruk

ctrlText ignores the last character

Recommended Posts

Example:

5014 is a RscEdit.

I write ASDF.

_string = ctrlText 5014;

hint format ["Text is %1", _string];

it returns "ASD"

But if I write ASDF . (notice the space at the end).

_string = ctrlText 5014;

hint format ["Text is %1", _string];

it returns "ASDF"

Share this post


Link to post
Share on other sites
Example:

5014 is a RscEdit.

I write ASDF.

_string = ctrlText 5014;

hint format ["Text is %1", _string];

it returns "ASD"

But if I write ASDF . (notice the space at the end).

_string = ctrlText 5014;

hint format ["Text is %1", _string];

it returns "ASDF"

Works for me without a hitch:

[color="#FF8040"][color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]spawn[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
[color="#191970"][b]findDisplay[/b][/color] [color="#FF0000"]46[/color] [color="#191970"][b]createDisplay[/b][/color] [color="#7A7A7A"]"RscCredits"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]with[/b][/color] [color="#191970"][b]uiNamespace[/b][/color] [color="#191970"][b]do[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
	ctrl [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]findDisplay[/b][/color] [color="#FF0000"]999[/color] [color="#191970"][b]ctrlCreate[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"RscEdit"[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]-1[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
	ctrl [color="#191970"][b]ctrlSetPosition[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]1[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0.1[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
	ctrl [color="#191970"][b]ctrlCommit[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color]
	[color="#191970"][b]hint[/b][/color] [color="#7A7A7A"]"Type something in RscEdit"[/color][color="#8B3E2F"][b];[/b][/color]
	[color="#191970"][b]sleep[/b][/color] [color="#FF0000"]10[/color][color="#8B3E2F"][b];[/b][/color]
	[color="#191970"][b]hint[/b][/color] [color="#191970"][b]format[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"You typed %1"[/color][color="#8B3E2F"][b],[/b][/color] [color="#191970"][b]ctrlText[/b][/color] ctrl[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

  • Like 1

Share this post


Link to post
Share on other sites

I've tested yours and it works fine.

My rscEdit define it's the following:

class RscEdit {
type = 2;
x = 0;
y = 0;
h = 0.04;
w = 0.2;
colorBackground[] = {0,0,0,1};
colorText[] = {0.95,0.95,0.95,1};
colorDisabled[] = {1,1,1,0.25};
colorSelection[] = {
	"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.69])",
	"(profilenamespace getvariable ['GUI_BCG_RGB_G',0.75])",
	"(profilenamespace getvariable ['GUI_BCG_RGB_B',0.5])",
	1
};
autocomplete = false;
text = "";
size = 0.2;
style = 0x00 + 0x40;
font = "PuristaMedium";
shadow = 2;
sizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
canModify = 1;
};

Type = 2 is #define CT_EDIT 2

I have no idea about how to fix this issue :/

EDIT:

The only thing I added is that it's capable to do multi-line.

Instead this:

"aaaaaaaaaaaaaaa"

this would display:

"aaaaaa

aaaaaaa"

EDIT2:

[] spawn {
findDisplay 46 createDisplay "RscCredits";
with uiNamespace do {
	ctrl = findDisplay 999 ctrlCreate ["RscEdit", -1];
[color="#FF0000"]		ctrl ctrlSetEventHandler ["Char", "var = ctrlText ctr; "];[/color]
	ctrl ctrlSetPosition [0,0,1,0.1];
	ctrl ctrlCommit 0;
	hint "Type something in RscEdit";
	sleep 5;
	[color="#FF0000"]hint format ["You typed %1 or %2", ctrlText ctrl, var];[/color]
};
};

I'm using something like this to get a variable. If I get the text with this the EH, the last character is always missing.

Edited by Icaruk

Share this post


Link to post
Share on other sites

Update:

0 spawn {
	findDisplay 46 createDisplay "RscCredits";

	ctrl = findDisplay 999 ctrlCreate ["RscEdit", -1];
	ctrl ctrlSetEventHandler ["Char", "test = ctrlText ctrl; "];
	ctrl ctrlSetPosition [0,0,1,0.1];
	ctrl ctrlCommit 0;
	hint "Type something in RscEdit";
	sleep 5;
	hint format ["You typed %1 or %2", ctrlText ctrl, test];
};

If you write 1234, the ctrlText will return 1234 but the "test" variable will return 123.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×