Topic: On MouseDown Event

Hi Dmitry,
I am trying to achieve the following in a small application.
1.  The user clicks and holds down the mouse button.  This executes an sql call and puts the result into a memo field which is then made visible and pops up on screen.
2.  When the user releases the mouse button, the memo field is cleared and hidden.
3.  I am doing this with 'on mouse down' and 'on mouse up' events.
It works well as a concept and is quick and easy for the user.
However, when you perform this on a different row in the tablegrid, the information in the memo field is for the previously selected record - so you have to first click on the row you are interested in to give that row focus AND THEN click and hold down the mouse - TWO separate actions.
Is there anyway by script that you can perform this as ONE action - click and hold down the mouse button and the row is given focus AND the sql call is executed?
I hope I've explained this clearly.
Thanks,
Derek.

Post's attachments

Attachment icon phonecalls.zip 339.99 kb, 421 downloads since 2017-08-07 

Re: On MouseDown Event

Interesting there Derek. I understand what you want to do and I don't have an answer either. Apparently the "SelectedRow" property does not get updated till the full click (down and up) is completed.  So hopefully Dimitry will have a way to do it. It actually could be the beginning stages of a drag and drop type functionality as well.


For the challenge I put together a kind of alternative to your situation. I'm sure you probably already tested various scenarios including what I have so my alternative will probably not be right for your project, but I included it here in case it may be a fit for someone else's projects.


A click on the magnifying glass in the tablegrid will show the call memo. Another click anywhere except the magnifying glass on another row will remove the memo.

Post's attachments

Attachment icon phonecalls Alt.zip 587.05 kb, 438 downloads since 2017-08-08 

Re: On MouseDown Event

Hello.



Check it out

procedure Form1_TableGrid1_OnMouseDown (Sender: string; MouseLeft, MouseRight, MouseMiddle: boolean; Shift, Alt, Ctrl: boolean; X, Y: Integer);
begin
 form1.memo1.Text := sqlexecute('select message from phonecalls where id =' +inttostr(Form1.TableGrid1.dbIndexToID(Form1.TableGrid1.GetRowAtPos(x,y))));
 form1.panel1.Visible := true;
end;
Dmitry.

Re: On MouseDown Event

Thank you Dimitry. Was not aware of GetRowAtPos(x,y). The help file does not have this particular definition. It will undoubtedly come in handy to know. I'm sure Derek will be pleased. Thanks again.

Re: On MouseDown Event

Hi Dmitry,
This is great - it does exactly what I want it to do now - I think this is going to be very useful in a lot of other applications.
Many thanks for your help.
.
Hi EHW,
Thanks for your interest and the alternative suggestion - I've not seen this sort of 'hot spot' clicking (for want of a better description) used in MVD before.  I think this, together with Dmitry's response using 'Get RowAtPos' is going to create new and interesting ways of designing tablegrid interactions for me.
.
Derek.

Re: On MouseDown Event

Hi Guys,


Nice question Derek...


Nice solution Dmitry...


Nice alternative solution EHW...


Thank you very much to all......................................

Adam
God... please help me become the person my dog thinks I am.