[comp.sys.mac.hypercard] Checking for field changes

kenk@tellab5.tellabs.CHI.IL.US (Ken Konecki) (04/07/89)

In article <1114@atux01.UUCP> jlc@atux01.UUCP (J. Collymore) writes:
> HOWEVER, I want to be able to have the field
>sense either a mouseClick, or KeyClick so that it will be able to tell me when a
>user has modified (i.e., tampered with a data in that field)!
>
>If anyone can tell me how to do this I would REALLY appreciate it.  Thanks

The easiest way to check for field changes is to have a closeField
handler for the field:
    on closeField
	-- Do what you need to do when the field is changed
    end closeField.

A good example is the address stack that comes with
Hypercard.  The address field has a closeField handler that puts
the date in the date field, so the date of last change is part of the
card. Of course, a closeField handler won't tell you that a field has
actually changed. A person might have just clicked in the field, then
changed her mind without modifying the text. Hypercard will still send
a closeField message when the user clicks elsewhere on the card.

Hope that helps,
    -Ken K
-- 
Ken Konecki
"A squeegee by any other name wouldn't sound as funny"
e-mail:kenk@tellab5.UUCP    -or-    ...!uunet!tellab5!kenk	
U.S. Mail: 1271 Portchester Circle, Carol Stream, IL 60188

stores@unix.SRI.COM (Matt Mora) (04/11/89)

In article <1266@tellab5.tellabs.CHI.IL.US> kenk@tellab5.UUCP (Ken Konecki) writes:
>In article <1114@atux01.UUCP> jlc@atux01.UUCP (J. Collymore) writes:
>> HOWEVER, I want to be able to have the field
>>sense either a mouseClick, or KeyClick so that it will be able to tell me when a
>>user has modified (i.e., tampered with a data in that field)!
>>
>>If anyone can tell me how to do this I would REALLY appreciate it.  Thanks
>
>The easiest way to check for field changes is to have a closeField
>handler for the field:
>    on closeField
>	-- Do what you need to do when the field is changed
>    end closeField.
>
There is also a brute force way to do it.  When the field is opened,
copy the field into a buffer. When the card is closed check the
buffer against the field to see if they are equal.

Its ugly but it should work.

On OpenField
 Global FieldBuff
 put field 1 into FieldBuff
end openField

On CloseField
 Global FieldBuff,FieldDirty
 if field 1 is equal to Fieldbuff then
  put false into FieldDirty
 else
  put true into FieldDirty
 end if
End CloseField

-- 
___________________________________________________________
Matthew Mora
SRI International                            stores@SRI.COM
___________________________________________________________

GFX@PSUVM.BITNET (04/11/89)

So far, this discussion seems to assume that we would be concerned by
_changes_ in field content.  But I can easily think of applications for
a function that would sense a word click _before_ any change has
occurred.  For example, you might want to allow a user to change field
contents, but may want to warn him; or give him some explanation regarding
the nature of the permissible changes.  We can always go around the limitations
(with a help button, be copying the initial content and asking to confirm
eventual changes if a closeFiled message is sent, etc...) but it could be
simpler.  Stephane

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (04/13/89)

In article <80695GFX@PSUVM> GFX@PSUVM.BITNET writes:
>So far, this discussion seems to assume that we would be concerned by
>_changes_ in field content.  But I can easily think of applications for
>a function that would sense a word click _before_ any change has
>occurred. [...]

The openField message is sent whenever the user clicks in a field (or
tabs into it). So a warning or reminder can be placed in the field's
openField handler, while any error checking can take place in a closeField
handler.

jeanne a. e. devoto
jdevoto@apple.com