tags:

views:

103

answers:

2

I have a master-detail window. In the detail window when I change a field and click on the master window, the focus changes but the itemchanged event of the detail datawindow isn't fired. Now I want to fire the itemchanged event when the focus changes from one datawindow to another datawindow.

P.S.: The itemchanged event is only firing if I change a field and press tab, or if I change a field and click inside a different field of the same datawindow.

+3  A: 

If the user enters the data and doesn't press tab, focus doesn't change. And itemchanged doesn't fire until the value is changed (and passes validation).

What's really happening here (if I'm remebering correctly) is that PowerBuilder puts an edit field over the actual datawindow; the datawindow never sees the new value until after PB gets the value out of the edit control.

You need to capture focus changed (onblur, I think?) or if that's not granular enough, keyup messages.

tpdi
I believe its actually 'LoseFocus', and then from there, trigger the itemchanged.
Zerofiz
How can I trigger itemchanged from losefocus? I have already tried it. I can get the current row, but how can I get the current column's control? Plus I need to pass the new data as an argument with the itemchanged event, how will I get that? If I can access that data then my problem is solved in the first place.
Night Shade
@tpdi: Thanks for your explanation..+1
Night Shade
+3  A: 

In the detail datawindow's 'LoseFocus' event, call AcceptText() on the detail datawindow.

Zerofiz
Bingo!!! Right On!!!
Night Shade
@Zerofiz: Can you explain a bit what just happened here?
Night Shade
Grimace. The problem analysis is correct, but then data validation fires at times like when the user tries to press the Cancel button. I know this is a popular and easy method, but it produces too many negative side effects for me. I'd put AcceptText()s where and when it makes sense, like the OK button, GetFocus on master when the last item with focus was detail, etc.... Have your application throw error messages just when you're switching apps to check your email (another time when your DW loses focus), and your users will be telling people PowerBuilder sucks. <beg>
Terry