Solved

left and right mouse button

Posted on 1998-11-22
6
127 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 100 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
Technology Partners: 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 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