Question 1: By returning 3 from itemerror
, you have rejected the data, which clears the column and triggers the itemchanged
again.
As to philosophically why PowerBuilder is designed to work in this fashion, I suspect they thought it would follow the principal of least surprise i.e. they were anticipating people asking why rejecting the input did not trigger itemchanged
.
Question 2: The itemchanged
event overrides itemerror
. In itemchanged
you rejected the input and prevented focus changing; in itemerror
you now accept the input, but you have not removed the block on focus changing. You should return 2 from itemchanged
, since you can then control whether you allow focus to change from the itemerror
event, by returning either 1 or 3.
In case anyone is reading this question without the powerbuilder help files handy:
return values for itemchanged
:
0 (Default) Accept the data value
1 Reject the data value and do not allow focus to change (triggers itemerror)
2 Reject the data value but allow the focus to change (triggers itemerror)
return values for itemerror
:
0 (Default) Reject the data value and show an error message box
1 Reject the data value with no message box
2 Accept the data value
3 Reject the data value but allow focus to change