|
Technical answers from the trenches |
|
Triggering ChangeValue() Events After Lookup
| ||||
Posted: 25 February 2003 |
||||
  |
Applies to: v5.0 and later |
|||
  |
Audience: Intermediate |
|||
Question: By default, Paradox doesn't trigger changeValue() events after table lookups. How do I fix it?Answer: Place the following code in the action() event of the field object bound to your lookup table: method action(var eventInfo ActionEvent)
var
atOldValue Anytype
endVar
if eventInfo.id() = dataLookup then
atOldValue = self.Value
doDefault
if eventInfo.errorCode() = peOK then
if atOldValue <> self.Value then
self.Value = self.Value
endIf
endIf
endIf
endMethodThis triggers the ChangeValue() event when focus moves to a different object. Followup question: Isn't this a bug?No, it's a design decision. Since changeValue is primarily used as a validation device and lookup tables, by definition, restrict the values in a field, the original designers of the Paradox event model felt that two validations were unnecessary. As a result, changeValue() events aren't fired as a result of data lookup actions. (Now, we can argue the wisdom of the actual decision, but what's the use?) However, changeValue() is also used to respond to values entered by the user. For example, you might:
Since these generally need to respond to data changes, changeValue() seems an appropriate candidate for that code. The above sample provides the desired effect, however, it may not the most appropriate way to accomplish your goals. Much depends on why you need this behavior. There may be other, more appropriate ways to achieve the same results. As with many subtleties of the Paradox event model, several approaches are available. While we've used this technique in our Paradox applications, we're always a little nervous when overriding the Paradox event model. It may be worth investigating alternate approaches. |
|||
|
||||||||
|
Copyright © 2000-2004, techtricks.com; All Rights Reserved. Acknowledgements, Disclaimers, Terms and Conditions. |
||||||||
|
Article last updated on 31 May 2003
|
||
|
|
||
|
[- End -]
|