如何在 VisualWorks Smalltalk 中主动更改标签的字符串
我试图在程序运行期间动态更改 ApplicationModel 中标签的值。 我尝试过:
(self builder labelAt: #Label4) labelString: 'Dynamic text here'.
但出现 labelString 无法理解的错误。 当我运行时:
(self builder labelAt:#Label4)
我得到“UndefinedObject”。这显然表明我没有返回我的 Label 对象。
I am trying to dynamically change the value of a label in an ApplicationModel dynamically during the running of my program.
I have tried:
(self builder labelAt: #Label4) labelString: 'Dynamic text here'.
But get a labelString not understood error.
When I run:
(self builder labelAt:#Label4)
I get "UndefinedObject". Which obviously suggests that I am not returning my Label object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
或
Try
or
如果您有一个用于更改值的模型,那么使用绑定到模型的只读 InputField 非常容易。我敢说,为不断变化的值建立一个模型通常是一个好主意。
如果将 InputField 定义为只读且没有边框,它将看起来与常规文本标签完全相同。从用户的角度来看,唯一的区别是能够从只读输入字段选择和复制文本,这在许多情况下很有用。
另一方面,标签可以具有更丰富的外观。您可以使用文本、组合文本或图像。
If you have a Model for your changing value it's pretty easy to use read-only InputField bound to your model. I dare to say having a Model for a changing value is generally a good idea.
If you define InputField as read-only and withou a border, it will look exactly like a regular text label. From a user's point of view the only difference is in ability to select and copy text from read-only input field, which is useful in many cases.
On the other hand, Labels can have a much richer look. You can use Text, ComposedText or Image for them.