Signalling events with arguments
In VA Smalltalk it is possible to signal an event with arguments using a method such as
self signalEvent: anEventName with: aValue
Objects are able to register themselves as dependents of an object and be notified when an event is signalled. One use of this is in the Composition Editor where an attribute-to-attribute connection is made. When either the source or the target signals the event associated with the attribute the other end of the connection will perform its set method associated with the attribute. For example, you can connect the object attribute of a text box to the object attribute of a label and when the text box signals its object event the label will update its object.
Prior to Version 4.5, the argument value that was passed into the with: keyword was ignored by the attribute connection which always went to the object that was raising the event and got the current value of the attribute. This had the effect that in some circumstantes the get method associated with the attribute would be triggered multiple times and also that you had no way of signalling an attribute-to-attribute connection to align itself with anything other than the current attribute value. Since Version 4.5, the value that is used as the argument to the with: keyword has been used to refresh the attribute, avoiding the need for the get method to be performed on the object that is raising the event.
You should be aware of this change in behavior as it will now expose methods that were previously passing incorrect values into the with: argument. For example, consider the method
firstName: aString
firstName := aString.
self signalEvent: #firstName with: aString.
This is the correct syntax. The event firstName is being signalled with the current value. Next, consider
firstName: aString
firstName := aString.
self signalEvent: #firstName with: self
This is incorrect. The event is signalled with self as the argument. If any methods exist that pass incorrect values to the with: keywords, they should be changed to either pass the correct arguments, or the keyword dropped.
firstName: aString
firstName := aString.
self signalEvent: #firstName
If there are no with: arguments, then the attribute-to-attribute connection will get the current value of the firstName attribute (by performing the get method) to align itself. It is preferable, however, to pass the value to the with: keyword if it is readily available.
To look for potential problems, evaluating the following methods will open browsers that show all methods that are signalling events with arguments. These can be inspected to make sure that the argument value used on the with: keyword is the correct one.
System allMethodsSending: #signalEvent:with:.
System allMethodsSending: #signalEvent:with:with:.
System allMethodsSending: #signalEvent:withArguments:.
 
Last modified date: 07/02/2019