Subject | Re: [IBO] Detecting user changes |
---|---|
Author | Geoff Worboys |
Post date | 2001-01-05T02:54:01Z |
> It appears that the TIB_SpinEditEnh does not trigger events<...>
> as expected.
Is this any different to normal edit controls? OnDataChange will fire
when a field value is updated. Controls only update the underlying
field value when...
- the user exits the control
- the dataset is posted
- the user presses enter (in Edit controls)
AFAICT this is the only practical way to implement this, since it is
possible that a controls contents may be temporarily invalid during
data entry (the value may be incomplete).
I suggested attaching to OnDataChange because your previous posting
implied you wanted to detect field level changes. OnDataChange will
find such changes regardless of whether they come from controls, grids
or code updates.
If you really want to attach code to changes in a particular control
(as opposed to changes to the field itself) then you will need to
attach to the OnChange event of the control. You can still test the
associated dataset edit state to see if you want the particular
change. Of course by using OnChange you still run across the problem
of partial inputs being incomplete and so invalid. So....
I guess SpinEdit is a slightly different beast in that clicking the
up/down arrows applies a new value "in full", and so it is unlikely
that such a value is invalid. You could attach code to the OnButton1
and OnButton2 event handlers (which are called immediately after the
increment/decrement is applied).
Of course the problem then is how to tell the control to commit its
change to the field buffer - and so force your DataSource.OnDataChange
to fire with appropriate field values. This could be forced by
sending a VK_RETURN keystroke to the control but this sort of thing
gets rather ugly. There are probably some things you could do to the
dataset/datasource but these are also less than elegant.
Jason, is there any reason why we cannot make a control's DataLink
public? This would allow (in the above situation) an event handler to
call...
IB_Edit1.DataLink.UpdateData;
Alternatively we should make an equivalent function available on the
controls themselves to perform this function.
I might stop rambling now. I guess the question is...
Shane, do you think that the ability to specifically call UpdateData
(to force the field update) may give you what you need? Or perhaps I
have lost the point somewhere (it would not be the first time :-)
Geoff Worboys
Telesis Computing