Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

left and right mouse button

Posted on 1998-11-22
6
Medium Priority
?
137 Views
Last Modified: 2010-04-04
hi,

in the onclick event I execute the code for the left mouse button, but how do I also execute a code for the rightmousebutton.

Something like this.

TForm1.Button1Click(Sender : TObject);
begin
if (leftmousebutton clicked??) then begin
...
end;
if (Rightmousebutton clicked??) then begin
...
end;
end;

Anyone knows the code for this...Thanks
0
Comment
Question by:hellfire052497
  • 3
  • 2
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1347542
hi hellfire,

try

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  case button of
    mbleft : edit1.text := 'LeftClick';
    mbright : edit1.text := 'RightClick';
  end;
end;

meikl
0
 
LVL 4

Accepted Solution

by:
jack_p50 earned 400 total points
ID: 1347543
Use onMouseUp/onMouseDown to see if some of buttons releases/presses.
Also you can use onMouseMove and check:
for left:            if ssLeft in Shift then...
for right:          if ssRight in Shift then...
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347544
and for right double click ?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:bryan7
ID: 1347545
and for right double click ?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1347546
hi bryan7,

this will it detects

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  case button of
    mbright : begin
                if ssdouble in shift then
                  edit1.text := 'DoubleRightClick'
                else
                  edit1.text := 'RightClick';
              end;
    mbleft  : Begin
                if ssdouble in shift then
                  edit1.text := 'DoubleLeftClick'
                else
                  edit1.text := 'LeftClick';
              end;
  end;
end;


meikl
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347547
yeah, great !!!!

thanx a lot.

bryan

0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question