From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:46:42 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>DependencyExample</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none colorNames fieldIsDependent selectedColor <imports></imports> <category>Examples-Help</category> <attributes> <package>Dependency-Example</package> </attributes> </class> <comment> Examples.DependencyExample
This example class demonstrates a technique for linking two widgets, in this case a list and a field.
</comment> <methods> Examples.DependencyExample <category>change messages</category>
changedDependency "Turn on or off the dependency link between the list and the input field, depending on the value of the check box." | valueModel | valueModel := self colorNames selectionIndexHolder. self fieldIsDependent value ifTrue: [valueModel onChangeSend: #changedSelection to: self] ifFalse: [valueModel retractInterestsFor: self].
changedSelection "In the input field, echo the color name that is selected in the list. This message is only sent when the dependency is turned on." self selectedColor value: self colorNames selection.
</methods> <methods> Examples.DependencyExample <category>aspects</category>
colorNames ^colorNames
fieldIsDependent ^fieldIsDependent
selectedColor ^selectedColor
</methods> <methods> Examples.DependencyExample <category>initialize-release</category>
initialize colorNames := SelectionInList with: ColorValue constantNames. selectedColor := String new asValue. fieldIsDependent := false asValue. "Arrange for the application model to take action when the check box is turned on or off." fieldIsDependent onChangeSend: #changedDependency to: self.
</methods> <methods> Examples.DependencyExample class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'DependencyExample' #min: #(#Point 40 20 ) #bounds: #(#Rectangle 267 359 451 698 ) ) #component: #(#SpecCollection #collection: #( #(#CheckBoxSpec #layout: #(#AlignmentOrigin 0 0.5 25 0 0.5 0 ) #model: #fieldIsDependent #label: 'Make field dependent' ) #(#SequenceViewSpec #layout: #(#LayoutFrame 10 0 60 0 -10 1 -50 1 ) #name: #colorNames #model: #colorNames ) #(#InputFieldSpec #layout: #(#LayoutFrame 10 0 -40 1 -10 1 -10 1 ) #model: #selectedColor ) ) ) )
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>ApplicationModel</name> <environment>UI</environment> <super>UI.Model</super> <private>false</private> none builder uiSession eventHandlers savedWindowInformation <imports></imports> <category>UIBuilder-Framework</category> <attributes> <package>UIBuilder-Framework</package> </attributes> </class>