简体   繁体   English

什么是Smalltalk中ActionButton的发件人?

[英]What is sender for ActionButton in Smalltalk?

I have 41 buttons that have to become Invisible when you click on them in VisualWorks. 当您在VisualWorks中单击它们时,我有41个按钮必须变为不可见。 It is just one line doing this. 这只是一条线。

(self builder componentAt: #buttonWhichCalledTheMethod) beInvisible.

I have tried going with self , but that is the whole form. 我尝试过self ,但这就是整个形式。

This context also produce error does not understand . This context也产生错误does not understand Both happens after I click on the button. 我点击按钮后都发生了这两种情况。

Is there any way to use something as sender? 有没有办法使用东西作为发件人?

I'm not sure I fully understand what you try to achieve. 我不确定我是否完全理解你想要实现的目标。 It seems you try to use the same code to make the button invisible that triggered the method you are currently running. 您似乎尝试使用相同的代码使按钮不可见,从而触发您当前正在运行的方法。 Due to decoupling of widgets and application code it's not really possible to guess which button triggered a certain method. 由于小部件和应用程序代码的分离,实际上不可能猜出哪个按钮触发了某个方法。 A simple solution would be to keep a dictionary where the selectors and button IDs are mapped and can be looked up. 一个简单的解决方案是保留一个字典,其中选择器和按钮ID被映射并可以查找。

The way these methods are called is via a block that's created in #actionFor: there the selector is passed, so if your buttons have the same ID as their selectors, you could override #actionFor: to not only perform the key but also disable the button. 这些方法被调用的方式是通过在#actionFor:创建的块#actionFor:在那里传递选择器,所以如果你的按钮与它们的选择器具有相同的ID,你可以覆盖#actionFor:不仅可以执行密钥而且还可以禁用按钮。

PS: don't ever use thisContext or #doesNotUnderstand: PS:永远不要使用thisContext#doesNotUnderstand:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM