|
| Editor onChange |
 |
Mon, 07 Apr 2008 07:28:26 -040 |
I have a 2.6.1.4 application in which I want display a MSGBOX if the user
changes the text in an Editor. To do this, I've put some fairly standard code in
the Editor's onChange event, as follows:-
MSGBOX('Text changed!','Warning',0+16)
RETURN
Now, when I change the text and move to another control, the message is duly
displayed, but I have to click the OK button twice to close it.
As far as I can see, this only occurs with Editors. Eg, if I do a similar thing
with an Entryfield, a single click closes the message box.
On searching the old newsgroup, I found a reference to this in a 2001 Bug
Report: 'Editor onChange firing twice'.
Hasn't this problem been fixed yet, or is there an easy workaround?
Thanks,
|
| Post Reply
|
| Re: Editor onChange |
 |
Mon, 7 Apr 2008 08:48:14 -0400 |
In article <oArR$JKmIHA.1688@news-server>, rod.jones@multi-base.co.uk
says...
>
> Hasn't this problem been fixed yet, or is there an easy workaround?
A solution would be to use the editor.onLostFocus() event handler.
In Form.onOpen function or in the rowset.onNavigate function, you could
add a line that says:
Form.oldText = Form.Editor1.value
Then, in the Editor1_onLostFocus function, you could have:
if NOT Form.editor1.value == Form.OldText
answer1 = msgBox("Should we save the changes", ;
" Save changes?",64 + 4)
if answer1 = 7 // Yes
...
else // No
Form.editor1.value = Form.oldText
endif
endif
Jean-Pierre Martel, editor
The dBASE Developers Bulletin
|
| Post Reply
|
| Re: Editor onChange |
 |
Tue, 08 Apr 2008 10:08:38 -040 |
Jean-Pierre Martel Wrote:
> A solution would be to use the editor.onLostFocus() event handler.
Thanks for the suggestion, Jean-Pierre. I had already tried a similar method but
because (rightly or wrongly) I normally set my pushbuttons' SpeedBar property to
true, this can lead to the form being closed before the change is detected and,
because I'm actually executing some further code after the change, this then
causes an error.
However, as it now seems clear that there's still a bug in the onChange event
that causes it to fire twice, I've thought of another workaround that overcomes
my problems. In the Editor's onGotFocus event, I've put:-
Form.Editor1_Onchange_fired=0
Then, in onChange, I've put:-
Form.Editor1_Onchange_fired = Form.Editor1_Onchange_fired + 1
IF Form.Onchange_fired=2
MSGBOX('Text changed!','Warning',0+16)
ENDIF
RETURN
So the message only appears after onChange has fired twice.
Thanks again,
|
| Post Reply
|
|
|
|
|
|
|
|
|
|