rhh 29 posts since
Oct 12, 2007
1.
Re: A simple question about "at" in the event handling block. Nov 7, 2007 8:57 AM
Tony,
In this case both approaches will work fine, and I don't think there is a strong reason to choose one over the other. But the use of "cb" in the event handler only works because the "let" statement defines the variable cb and binds it to the CheckButton. In some situations, there is no variable that's permanently bound to the button. For example, you might have some code like the following somewhat contrived example:
{HBox
{CheckButton label="First",
{on ValueChanged at b:CheckButton do
{popup-message {format "First is %s", b.value}}
}
},
{CheckButton label="Second",
{on ValueChanged at b:CheckButton do
{popup-message {format "Second is %s", b.value}}
}
}
}
In this case, the "b" in the "at" clause is the only way to get a name for the CheckButton so its value can be accessed.