From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:47:09 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>FieldFilterExample</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none password <imports></imports> <category>Examples-Help</category> <attributes> <package>FieldFilter-Example</package> </attributes> </class> <comment> Examples.FieldFilterExample
This example class demonstrates a technique for filtering input to an input field, by including a test in the message invoked on #onChangedSend:.
</comment> <methods> Examples.FieldFilterExample <category>change messages</category>
filterPassword "Remove anything that isn't a letter or a digit from the password input." | entry cleanedPassword lengthLimit | entry := self password. lengthLimit := 6. "Turn off dependency to avoid recursive invocation of this method." entry retractInterestsFor: self. "Filter out invalid characters." cleanedPassword := entry value select: [ :char | char isAlphaNumeric]. "If the password is too long, warn the user (and reject the input)." cleanedPassword size > lengthLimit ifTrue: [Dialog warn: 'Please enter only ', lengthLimit printString, ' letters or digits.'] ifFalse: [entry value: cleanedPassword]. "Reestablish the dependency." entry onChangeSend: #filterPassword to: self.
</methods> <methods> Examples.FieldFilterExample <category>initialize-release</category>
initialize super initialize. password := 'guest' asValue. password onChangeSend: #filterPassword to: self
</methods> <methods> Examples.FieldFilterExample <category>aspects</category>
password ^password
</methods> <methods> Examples.FieldFilterExample class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'FieldFilterExample' #min: #(#Point 50 50 ) #bounds: #(#Rectangle 310 319 510 410 ) ) #component: #(#SpecCollection #collection: #( #(#InputFieldSpec #layout: #(#Rectangle 24 40 181 68 ) #model: #password #type: #string ) ) ) )
</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>