Board index » delphi » Right button click

Right button click

Greetings!

Sorry if this has been discussed before, but I'm very new to
Delphi. Is there any way to get a simple button to distinguish with which
mouse button it has been click upon? For example, is it possible to call
one event handler when the left button was pressed and a different one
when the right button was pressed?

TIA

Harold

 

Re:Right button click


Use the MouseDown event and it's Button parameter (see the Delphi Online
Help for details).
But I think it would also be very useful for you to buy a good Delphi book;
this was quite a basic question. See what you can get, I used 'Teach
yourself Delphi 3 in 14 days' by Batson, Osier and Grobman, and i was
satisfied with it....

Regards,
IByte

- If debugging is the art of removing bugs,
- then programming is the art of inserting them.

Quote
Harold Weiss-Wallrath <har...@laprivan.localhost> wrote in message

news:dfr8i8.qp.ln@laprivan...
Quote

> Greetings!

> Sorry if this has been discussed before, but I'm very new to
> Delphi. Is there any way to get a simple button to distinguish with which
> mouse button it has been click upon? For example, is it possible to call
> one event handler when the left button was pressed and a different one
> when the right button was pressed?

> TIA

> Harold

Re:Right button click


Use the MouseDown event and it's Button parameter (see the Delphi Online
Help for details).
But I think it would also be very useful for you to buy a good Delphi book;
this was quite a basic question. See what you can get, I used 'Teach
yourself Delphi 3 in 14 days' by Batson, Osier and Grobman, and i was
satisfied with it....

Regards,
IByte

- If debugging is the art of removing bugs,
- then programming is the art of inserting them.

Quote
Harold Weiss-Wallrath <har...@laprivan.localhost> wrote in message

news:dfr8i8.qp.ln@laprivan...
Quote

> Greetings!

> Sorry if this has been discussed before, but I'm very new to
> Delphi. Is there any way to get a simple button to distinguish with which
> mouse button it has been click upon? For example, is it possible to call
> one event handler when the left button was pressed and a different one
> when the right button was pressed?

> TIA

> Harold

Re:Right button click


Quote
Harold Weiss-Wallrath wrote:

> Is there any way to get a simple button to distinguish with which
> mouse button it has been click upon?

Yes, use the Button's MouseDown event:

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
   if (Button = mbRight)
   then ShowMessage('Right button')
   else ShowMessage('Left button');
end;

Markku Nevalainen

Other Threads