• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 794
  • Last Modified:

Emulate mouse click on row in datawindow

Greetings All,

I have some code that selects a row in a datawindow.  It works fine.  But after I select and highlight the row, I want to emulate clicking on that row once.

Can't seem to figure it out.  Here is the code along with a note as to where I want to emulate the click.

dw_2.SelectRow(0,false)
dw_1.reset()

long i
string confo
string confo2
confo2 = em_1.text
//messagebox("confo2 from em_1",confo2)

for i = 1 to dw2retrievedrows
      
      confo = dw_2.getitemstring(i,"compute_3")
      confo = right(confo,4)
      //messagebox("confo and confo2", confo + " " + confo2)
            if confo = confo2 then
                  dw_2.selectrow(i, true)
                  dw_2.SetRow(i)
                  dw_2.scrolltorow(i)
                  dw_2.setfocus()
                                                //emulate mouse click on dw_2 here...

                  return
            end if
      next

Thank you all for your help in advance!!

PEM
0
pemurray
Asked:
pemurray
  • 4
  • 4
1 Solution
 
diasroshanCommented:
Hi,

i hope u have code written in the DW_2 clicked event... and u can call this code by the following syntax...

dw_2.Triggerevent(Clicked!)


So ur code will look like this...

dw_2.SelectRow(0,false)
dw_1.reset()

long i
string confo
string confo2
confo2 = em_1.text
//messagebox("confo2 from em_1",confo2)

for i = 1 to dw2retrievedrows
     
     confo = dw_2.getitemstring(i,"compute_3")
     confo = right(confo,4)
     //messagebox("confo and confo2", confo + " " + confo2)
          if confo = confo2 then
               dw_2.selectrow(i, true)
               dw_2.SetRow(i)
               dw_2.scrolltorow(i)
               dw_2.setfocus()

                dw_2.Triggerevent(Clicked!)                                //emulate mouse click on dw_2 here...

               return
          end if
     next

Cheers,
Rosh
0
 
pemurrayAuthor Commented:
Hey Rosh,

Okay, I inserted the line as specified:

dw_2.Triggerevent(Clicked!)                                //emulate mouse click on dw_2 here...

And yes, I do have code in my dw_2.clicked event (which automatically retrieves data in dw_1).

I ran the code, but I don't see any difference.  The row is highlighted as before, but it doesn't refresh the data.  Do I have to write a new event or something like that?

Thanks!!

Paul
0
 
LordainCommented:
Hi Paul,

I can see from what has been posted so far that yes you would highlight a matching row but the problem you are going to run into is you are not telling PB which row you have clicked and you are trying to fire of the clicked event without any parameters.

I believe what is going to actually happen is PB will believe the row = 0.

Are you trying to use the parameters of the clicked event or are you trying to process the clicked event?

Since I am not certain what your actual goal is I can offer some directional advice.

Write a function or user event which will accept the row as an argument and let it do whatever processing you want to carry out.

Therefore replace

dw_2.Triggerevent(clicked!) with

long ll_row
ll_row = dw_2.getrow( )
of_simulate_click(this, ll_row)

Function of_simulate_click(datawindow dw, long row) returns long (or whatever)

//From here you can get any object and/or its data and do whatever you want with it.

----
Otherwise tell me what you are actually trying to do for your clicked event and perhaps I can give you a more specific way of handling what you are trying to accomplish.




0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
pemurrayAuthor Commented:
Hi Lordain,

Once the code is done with the scrolltorow() where it highlights the correct row in dw_2, I want to emulate a click on dw_2 on the highlighted (selected) row.

I have created some functions, but more along the line of argument a, argument b, return a*b.

So are you defining a function on the fly here or do I have to go into the function painter?

I can paint, but I am not sure what would go into the logic...

Please, whatever is easiest to clickk on the selected row.

Thanks!!

PEM
0
 
LordainCommented:
Ok but once you emulate the click what are you wanting it to do?  What is in your clicked! event?
0
 
pemurrayAuthor Commented:
Hi Lordain,

I have code in my dw_2 clicked event that I want to fire.  Basically, it does row = dw_2.getclickedrow() and then does a retrieve on dw_1.

Right now the agents are using the software, but they have to look at the row that is highlighted and then click on the highlighted row.  Then the clicked event fires (for that row) and it retrieves the correct information for dw_1.

Thanks for your help!!

PEM
0
 
LordainCommented:
You have the row number in DW_2 as the variable i from your posted example.  You could just code the following:

dw_1.retrieve( i ) //presuming you are using i as an argument.

No need to fire the clicked event.  I was able to successfully call the clicked! event but all the values are null which I expected it to be null or 0.

This is why I was asking what you were actually trying to accomplish inside the clicked event to determine the requirement to see if there was a better alternative.
0
 
pemurrayAuthor Commented:
BINGO!!

Lordain,

That worked like a charm!!  Very clean solution!!

Thank you, Sir!!

PEM
0
 
LordainCommented:
Glad to hear and good coding to you.
0
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now