Jump to content

Text Field bugged (I already have a workaround, but plz fix)


Go to solution Solved by Josh,

Recommended Posts

Posted

Hey there,

the following code example will make a text field which is rather big and can be applied to the example project if replaced by line  141 and following.
 


	auto styleTextArea = CreateTextField(border, border + 40, subpanel2->ClientSize().x - 2 * border, subpanel2->ClientSize().y - 2 * border - 40, subpanel2);
	styleTextArea->SetAlignment(1, 1, 1, 1);
	styleTextArea->SetText("		#my_iframe{\n		position: absolute;\n		top: 0px;\n		left: 0px;\n		width: 100%;\n		height: 100%;\n		border:0;\n		}\n\n		#hide_button, #show_button{\n		position: absolute;\n		width: 100px;\n		height: 30px;\n			background-color: DodgerBlue;\n		color: white;\n			text-align: center;\n			line-height: 30px;\n		cursor: pointer;\n		}\n\n			#hide_button{\n		left: 10px;\n		}\n\n			#show_button{\n		left: 120px;\n		}\n");

In the latter code example i put the whole text thing in one line , but using my original approach made it even buggier : 
 


#define MULTI_LINE_STRING(a) #a

struct styleTextTemplate{
	const char* text = MULTI_LINE_STRING(
		#my_iframe{\n
		position: absolute;\n
		top: 0px;\n
		left: 0px;\n
		width: 100%;\n
		height: 100%;\n
		border:0;\n
		}\n\n

		#hide_button, #show_button{\n
		position: absolute;\n
		width: 100px;\n
		height: 30px;\n
			background-color: DodgerBlue;\n
		color: white;\n
			text-align: center;\n
			line-height: 30px;\n
		cursor: pointer;\n
		}\n\n

			#hide_button{\n
		left: 10px;\n
		}\n\n

			#show_button{\n
		left: 120px;\n
		}\n
		);
};

// and use setText
auto styleTextArea = CreateTextField(border, border + 40, subpanel2->ClientSize().x - 2 * border, subpanel2->ClientSize().y - 2 * border - 40, subpanel2);
	styleTextArea->SetAlignment(1, 1, 1, 1);
	styleTextTemplate style;
	styleTextArea->SetText(style.text);

EDIT: Sorry wrong category

Posted

So you are just saying that adding a string with line returns causes it to display wrong?

My job is to make tools you love, with the features you want, and performance you can't live without.

  • Solution
Posted

I just updated the program. The TextField::SetText method will strip the \n and \r characters from the inputted text.

My job is to make tools you love, with the features you want, and performance you can't live without.

  • Josh locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...