powerbuilder triggerevent example

Lets suppose that we have a window with two datawindow in it dw_1, dw_2 and two push buttons pb_1 pb_2.

pb_2 clicked event contains the following code
x1 = 1

pb_1 clicked event contains the following code
x1 = 2
messagebox("hi", string(x1))

my problem is that when i press pb1 button  pb2 clicked event is fired (x1 = 1) but dw_2 is receiving focus after the execution of messagebox command and not before it as i expected. Can i bypass this problem somehow (possibly with another technique)? i know than i can use a
responsed window containing dw_2 instead. i am interested in another solution if possible.

Who is Participating?
Here's a trick we use to delay a messagebox. Create a new function in you n_appmanager:

of_postmessage return long  with 2 arguments:
string as_title
string as_msg

long ll_rc

ll_rc = MessageBox(as_title, as_msg)

Return ll_rc

Then in your code use this:

gnv_app.Post of_PostMessage('hi', String(x1))

Since you are posting this, there is no way to capture the return from the function so you cannot use this trick if you need to know which button they clicked but for OK messages, this works nicely.

You can also write a similar function if you are using the MESSAGES table and the inv_error.of_Message function. If you are, I can send you that function as well.
I am sure your datawindow is getting focus first, but you are displaying message immediately after that and hence focus is now on message box and once you close message box, it goes back to datawindow.

Write messagebox('','focus') in getfocus event of dw_2 and you will see that it's getting a focus before or not.

basilhs_sAuthor Commented:
i used the messagebox to show that dw_2 receive the focus after the completion of pb1 clicked event.
basilhs_sAuthor Commented:
thanks very much
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.