如何将 LabelMorph/TextMorph 绑定到变量,以便 Morph 反映变量的变化? [英] How to bind a LabelMorph/TextMorph to a variable so that the Morph reflects changes of the variable?

查看:21
本文介绍了如何将 LabelMorph/TextMorph 绑定到变量,以便 Morph 反映变量的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我有一个包含字符串的变量的对象.
  • 我有一个包含 LabelMorph/TextMorph(或其他显示文本的 Morph?)的窗口.

如何将 LabelMorph/TextMorph 绑定到变量,以便在变量中的 String 更改时标签更新?

How do i bind the LabelMorph/TextMorph to the variable, so that the label updates when the String in the variable changes?

  • 经典的 Smalltalk-80 依赖/更改/更新机制?
  • Pharo 公告框架?
  • 有什么不同??

我该怎么做?我应该使用哪种 Morph?

How would i do this? Which Morph should i use?

推荐答案

取决于您想要实现的目标.您可能想看看在当前 Moose 图像中使用 Glamour 的方法.在工作区中,做:

Depends on what you want to achieve. You might want to take a look at a way to do it with Glamour in a current Moose image. In a workspace, do-it:

GLMBasicExamples new magritte openOn: GLMMagrittePersonExample sampleData 

这显示了如何处理保存时的通知.前面的示例是开始了解如何使用 Glamour 的更好方法(并且由于 examplebrowser 的构建方式,Magritte 示例在嵌套时不会更新列表):

That shows how to work with announcements on save. The earlier examples are a better way to start understanding how to work with Glamour (and because of the way the examplebrowser is build, the Magritte example doesn't update the list when it is nested):

GLMBasicExamples open

还有其他几个随着变化而更新的例子.

That has several other examples that update on change.

这篇关于如何将 LabelMorph/TextMorph 绑定到变量,以便 Morph 反映变量的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆