View Full Version : Displaying the value of a variable using <text>
jhambley@mac.co
04-02-2004, 12:21 PM
How do you display the value of a <inputtext> variable using <text> ?
antun
04-02-2004, 12:36 PM
You could constrain it:
<inputtext id="foo" width="200" />
<text width="200" text="${foo.text}" />
Or you could have the inputtext change the text of the text field:
<inputtext width="200" ontext="bar.setText(this.text)"/>
<text width="200" id="bar" />
There's other ways too - you could have some other event copy the text over (e.g. the click of a button).
You might also have a variable somewhere that's bound to the inputtext field, and have the text field bound to that.
-Antun
jhambley@mac.co
04-02-2004, 01:16 PM
The top section displays help twice. If I comment out the top code and run the bottom example I only see the <inputtext>
text.
Can you help?
<canvas width="800" height="600">
<!-- This works -->
<view name="panel1" width="300" height="300">
<text id="foo" width="200" text="Help"/>
</view>
<view name="panel2" width="300" height="300" y="300">
<text width="200" text="${foo.text}" />
</view>
<!-- This doesn't work -->
<view name="panel1" width="300" height="300">
<inputtext id="foo" width="200" text="Help"/>
</view>
<view name="panel2" width="300" height="300" y="300">
<text width="200" text="${foo.text}" />
</view>
</canvas>
vfunshteyn
04-02-2004, 02:20 PM
Constrain the text attribute of the second field to foo.getText():
<view name="panel2" width="300" height="300" y="300">
<text width="200" text="${foo.getText()}" />
</view>
I would also recommend developing your code with the debugger enabled, as it catches runtime errors like the one in your example, which makes troubleshooting a whole lot easier.
antun
04-02-2004, 02:37 PM
I think the problem is that:
a) You're not positioning the elements so they don't overlap. Use <simplelayout /> or separate out the views them absolutely using x and y attributes.
b) There are two elements in your app with an id of foo. ids are supposed to be global. They're a convenient way of showing concepts so you don't have to address views using dot syntax (e.g. parent.parent.myview...), because you can reference a view using an id from anywhere. Of course that means that all the ids you use must be unique.
-Antun
vfunshteyn
04-02-2004, 02:42 PM
Originally posted by antun
I think the problem is that:
a) You're not positioning the elements so they don't overlap. Use <simplelayout /> or separate out the views them absolutely using x and y attributes.
b) There are two elements in your app with an id of foo. ids are supposed to be global. They're a convenient way of showing concepts so you don't have to address views using dot syntax (e.g. parent.parent.myview...), because you can reference a view using an id from anywhere. Of course that means that all the ids you use must be unique.
-Antun
No, neither one of those is the case here (I tested the example). You just can't seem to constrain anything to the text attribute of an inputtext element; getText() must be used instead -- I'm not sure if it's intentional or not.
you have to call getText() to get text out of an inputtext field. don't use the .text property
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.