文本区域叠加在另一个字符串之上

huangapple go评论76阅读模式
英文:

TextArea with string on top of another string

问题

textArea有一个显示字符串值的textArea。我有一个带有eventHandler的按钮。当我按下这个按钮时,我想要添加另一个字符串和新值(将其添加到前一个值)。我正在使用

textArea.appendText(" string" + cost);

但是这会将其添加到textArea中前一行的旁边,但我希望这一行位于其下方。我一直没有找到可以替代append的方法。是否有一种在下方添加新行的方法?

英文:

I Have a textArea that displays a string with a value. I have a button with an eventHandler attached. When I press this button, I want to add another string and new value (which adds to the prev value). I am using

textArea.appendText( " string" + cost);

But this is adding it next to the previous line in the textArea, but I want this line to be below it. I
have not been able to find a method to use instead of append. Is there a way to add the new line below?

答案1

得分: 0

Use "\n" 用于换行,在每个需要换行的字符串之间添加。

英文:

Use "\n" for new line, one each string that you want to be on a new line

答案2

得分: 0

Append your text with an Escape Sequence("\n").
This should put the new line below it.

You can do something like this:

textArea.appendText("\n" + cost);
英文:

Append your text with an Escape Sequence("\n").
This should put the new line below it.

You can do something like this:

textArea.appendText("\n" + cost);

huangapple
  • 本文由 发表于 2020年4月6日 17:17:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/61056504.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定