I've recently started programming with EjsS and one of the problems I've come across is when using multiple text areas for displaying strings. As far as I know, you have two predefined methods: _view.print() and _view.println() which enables you to print a string in the last text area created. But, what code or method would you use for displaying text strings in text areas created before the last one, for which both aforementioned methods don't work? I have tried using view.print(), but I might be doing something wrong...
You could assign boolean variables such as show displacement to be turn true or false depending on whether it is as you designed, to show that variable drawing.
See my example http://iwant2study.org/ospsg/index.php/interactive-resources/physics/01-measurements/19-decomposition-of-vector-any-mutually-perpendicular-advance-model
Re: Re: view.print() method for multiple text areas -
Alberto Porras
5 Posts
Thank you for your reply. Nevertheless, I don't quite understand your method... The thing is, you have two text areas: text area A and text area B, in which you want do display string A and string B (string A in text area A and string B in text area B). The last text area created was text area B. Therefore, if I use _view.print(string A) the string would be displayed in text area B, because it's the last one created. What code would you then use to display string A in text area A? If I look at the properties of a text area, you can't assing it any variables, just its title, if it's editable or not, its visibility, etc.
Re: Re: view.print() method for multiple text areas -
Alberto Porras
5 Posts
Hi, Paco,
I have a text area called "Operations", and I have tried using both print a and println the same way you did to print in the string "TEST". In both cases I got errors, for which I send you pictures of the corresponding messages.
What did I wrong this time? Could it be that I have to define the "Operations" text area as an object in the variables tab?
Thank you!
Alberto
Edit: I have come up with two solutions, the first one being _view.TextArea.setText("whatever"), which prints and deletes the previous strings printed in the same text area, and _view.TextArea.append("whatever"). In any case, I would still like to know what could be the reasons the previous methods have failed, in order to learn and improve for future occasions. Thank you in advance!