Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-08

TShiftstate

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alex du Plessis

I am trying to check a shift state in an onMouseUp event

if shift=ssShift then

but when I compile this I get an error

E:\DataRoot\Projects\DelphiConversions\Mathparsers\LXExpParser\Source\lxmathstringgrid.pas(132,11) Error: Incompatible types: got "TShiftStateEnum" expected "TShiftState"

When I look in classesh.inc (where it is defined) there is a strange definition

{$packset 1}
  TShiftState = set of TShiftStateEnum;
{$packset default}

How do I check my shift state and get around this compiler error?

Regards

Alex du Plessis

Reply by email

Howard Page-Clark
to Alex du Plessis

Hi

Because shift is of type set (not an integer or some other variable type) you cannot test for equality as you would for integer variables with the algebraic "=" sign. The syntax needed is:

if (ssShift in shift) then .

Howard

Earlier message 32 lines
----- Original Message ----- From: "Alex du Plessis" To: "Lazarus mailing list" Sent: Wednesday, August 06, 2008 4:15 PM Subject: [Lazarus] TShiftstate >I am trying to check a shift state in an onMouseUp event > > if shift=ssShift then > > but when I compile this I get an error > > E:\DataRoot\Projects\DelphiConversions\Mathparsers\LXExpParser\Source\lxmathstringgrid.pas(132,11) > Error: Incompatible types: got "TShiftStateEnum" expected "TShiftState" > > When I look in classesh.inc (where it is defined) there is a strange > definition > > {$packset 1} > TShiftState = set of TShiftStateEnum; > {$packset default} > > How do I check my shift state and get around this compiler error? > > Regards > > Alex du Plessis > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Paul Ishenin
to Alex du Plessis: I am trying to check a shift state in an onMouseUp event if shift=ssShift then but when I…
Alex du Plessis wrote
I am trying to check a shift state in an onMouseUp event if shift=ssShift then
if you want to check if shift is pressed then

[code]
if ssShift in shift then
[/code]

or

[code]
if [ssShift] * shift [] then
[/code]

if you want to check if only shift modifier is pressed and no other modifiers are pressed (ctrl, alt, mouse buttons) then

[code]
if shift = [ssShift] then
[/code]

Best regards,
Paul Ishenin.

Reply by email

Alex du Plessis
to Howard Page-Clark: Hi Because shift is of type set (not an integer or some other variable type) you cannot…

Of course, that was completely dumb of me > Why I did not notice that is beyond me.

My apologies

Alex

Howard Page-Clark wrote 42 lines
Hi Because shift is of type set (not an integer or some other variable type) you cannot test for equality as you would for integer variables with the algebraic "=" sign. The syntax needed is: if (ssShift in shift) then . Howard ----- Original Message ----- From: "Alex du Plessis" To: "Lazarus mailing list" Sent: Wednesday, August 06, 2008 4:15 PM Subject: [Lazarus] TShiftstate > I am trying to check a shift state in an onMouseUp event > > if shift=ssShift then > > but when I compile this I get an error > > E:\DataRoot\Projects\DelphiConversions\Mathparsers\LXExpParser\Source\lxmathstringgrid.pas(132,11) > Error: Incompatible types: got "TShiftStateEnum" expected "TShiftState" > > When I look in classesh.inc (where it is defined) there is a strange > definition > > {$packset 1} > TShiftState = set of TShiftStateEnum; > {$packset default} > > How do I check my shift state and get around this compiler error? > > Regards > > Alex du Plessis > >

Reply by email