Board index » delphi » TShiftState and mouseup

TShiftState and mouseup

Hi,

I need to check which mouse button called the OnMouseUp event.  However,
when I test the TShiftState for ssLeft or ssRight it always seems to be
empty. Am I missing something (the shiftstate works fine in the onmousedown
event) or can someone tell me how to check which mouse button triggered the
OnMouseUp event.

Many Thanks

Ian

 

Re:TShiftState and mouseup


On Mon, 10 Feb 2003 09:54:59 -0000, "IanJ" <ijohans...@bigfoot.com>
wrote:

Quote
>Hi,

>I need to check which mouse button called the OnMouseUp event.  However,
>when I test the TShiftState for ssLeft or ssRight it always seems to be
>empty. Am I missing something (the shiftstate works fine in the onmousedown
>event) or can someone tell me how to check which mouse button triggered the
>OnMouseUp event.

>Many Thanks

>Ian

You have to check the Button parameter, not the Shift one
e.g.
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
                             Shift: TShiftState; X, Y: Integer);
begin
  case Button of
    mbLeft   : { do something      }
    mbRight  : { do something else }
    mbMiddle : { do another thing }
  end;
end;

the Shift parameter is relative to keyboard state.

Regards
Maurizio

Re:TShiftState and mouseup


Thanks Maurizio - got confused when reading the help on TShiftState

Quote
"Maurizio Ferreira" <maurizio.ferre...@selesta.it> wrote in message

news:2r2f4vo7uck1bi0qldf4j5iiepi8l3ade9@4ax.com...
Quote
> On Mon, 10 Feb 2003 09:54:59 -0000, "IanJ" <ijohans...@bigfoot.com>
> wrote:

> >Hi,

> >I need to check which mouse button called the OnMouseUp event.  However,
> >when I test the TShiftState for ssLeft or ssRight it always seems to be
> >empty. Am I missing something (the shiftstate works fine in the
onmousedown
> >event) or can someone tell me how to check which mouse button triggered
the
> >OnMouseUp event.

> >Many Thanks

> >Ian

> You have to check the Button parameter, not the Shift one
> e.g.
> procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
>                              Shift: TShiftState; X, Y: Integer);
> begin
>   case Button of
>     mbLeft   : { do something      }
>     mbRight  : { do something else }
>     mbMiddle : { do another thing }
>   end;
> end;

> the Shift parameter is relative to keyboard state.

> Regards
> Maurizio

Re:TShiftState and mouseup


Quote
"IanJ" <ijohans...@bigfoot.com> wrote in message

news:3e477776$1@newsgroups.borland.com...

Quote
> Hi,

> I need to check which mouse button called the OnMouseUp event.  However,
> when I test the TShiftState for ssLeft or ssRight it always seems to be
> empty. Am I missing something (the shiftstate works fine in the
onmousedown
> event) or can someone tell me how to check which mouse button triggered
the
> OnMouseUp event.

Most probably the one that triggered mousedown. :)

ShiftState if is the state of certain keys and mouse buttons. Button
parameter says which button triggered the action, which isn't necessarily
reflected in ShiftState.

--
Robert Cerny

Other Threads