Re: modifier-flags with no key pressed and mouseDown 256, why?

2009-01-17 Thread Dave DeLong

Good to know!  Thanks for the info.  =)

Dave

On 16 Jan, 2009, at 4:47 PM, Shawn Erickson wrote:

On Fri, Jan 16, 2009 at 2:29 PM, Shawn Erickson   
wrote:
On Fri, Jan 16, 2009 at 1:15 PM, Dave DeLong   
wrote:

My understanding is that the modifierFlag "256" means that no other
modifiers are pressed.  I haven't found it in the docs anywhere,  
but I
believe that you can count on "256" meaning "no flags".  Every  
machine I've
tested this on (I've done a bunch of CGEvent stuff recently) seems  
to agree.


Unsafe assumption. You are just lucky that some lower bit (device
dependent bit) is being set for you. I know of no documentation that
says this bit will always set. Additionally if some other device
dependent bit is set your assumption would be broken.


As a follow up you are depending on kCGEventFlagMaskNonCoalesced being
set if you are checking against a numeric value of 256. IIRC this will
not be set for events coming from event sources created with
kCGEventSourceStatePrivate and possibly other avenues.

-Shawn


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: modifier-flags with no key pressed and mouseDown 256, why?

2009-01-16 Thread Alexander Reichstadt

Thanks for all the input, makes sense.

Alex

On 16.01.2009, at 23:29, Shawn Erickson wrote:

On Fri, Jan 16, 2009 at 1:15 PM, Dave DeLong   
wrote:

My understanding is that the modifierFlag "256" means that no other
modifiers are pressed.  I haven't found it in the docs anywhere,  
but I
believe that you can count on "256" meaning "no flags".  Every  
machine I've
tested this on (I've done a bunch of CGEvent stuff recently) seems  
to agree.


Unsafe assumption. You are just lucky that some lower bit (device
dependent bit) is being set for you. I know of no documentation that
says this bit will always set. Additionally if some other device
dependent bit is set your assumption would be broken.

-Shawn
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/lxr%40mac.com

This email sent to l...@mac.com




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: modifier-flags with no key pressed and mouseDown 256, why?

2009-01-16 Thread Shawn Erickson
On Fri, Jan 16, 2009 at 2:29 PM, Shawn Erickson  wrote:
> On Fri, Jan 16, 2009 at 1:15 PM, Dave DeLong  wrote:
>> My understanding is that the modifierFlag "256" means that no other
>> modifiers are pressed.  I haven't found it in the docs anywhere, but I
>> believe that you can count on "256" meaning "no flags".  Every machine I've
>> tested this on (I've done a bunch of CGEvent stuff recently) seems to agree.
>
> Unsafe assumption. You are just lucky that some lower bit (device
> dependent bit) is being set for you. I know of no documentation that
> says this bit will always set. Additionally if some other device
> dependent bit is set your assumption would be broken.

As a follow up you are depending on kCGEventFlagMaskNonCoalesced being
set if you are checking against a numeric value of 256. IIRC this will
not be set for events coming from event sources created with
kCGEventSourceStatePrivate and possibly other avenues.

-Shawn
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: modifier-flags with no key pressed and mouseDown 256, why?

2009-01-16 Thread Shawn Erickson
On Fri, Jan 16, 2009 at 1:15 PM, Dave DeLong  wrote:
> My understanding is that the modifierFlag "256" means that no other
> modifiers are pressed.  I haven't found it in the docs anywhere, but I
> believe that you can count on "256" meaning "no flags".  Every machine I've
> tested this on (I've done a bunch of CGEvent stuff recently) seems to agree.

Unsafe assumption. You are just lucky that some lower bit (device
dependent bit) is being set for you. I know of no documentation that
says this bit will always set. Additionally if some other device
dependent bit is set your assumption would be broken.

-Shawn
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: modifier-flags with no key pressed and mouseDown 256, why?

2009-01-16 Thread Shawn Erickson
On Fri, Jan 16, 2009 at 1:08 PM, Alexander Reichstadt  wrote:
> Hi,
>
> I have a phenomenon I am exploiting but unless I know for sure why it works
> must stop to use. The objective is to make sure that while the mousebuttons
> is being pressed no other modifier key is pressed, if anything is pressed
> the whole method return. Testing for 256 seems to work, why?
>
>NSUInteger  modifierFlags = [currentEvent modifierFlags];
>if (modifierFlags!=256) return;

This is a bit field so I personally prefer to work with it as such...

if ((modifierFlags & NSDeviceIndependentModifierFlagsMask)) == 0) {
 // no standard modifier is pressed
} else {
 // some standard modifier is pressed
}

-Shawn
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: modifier-flags with no key pressed and mouseDown 256, why?

2009-01-16 Thread Alexander Reichstadt
Thanks Dave, if someone still has a reference or headerfile or can  
point me to something from which I can logically deduce that this will  
hold true, it would help a lot.


On 16.01.2009, at 22:15, Dave DeLong wrote:

My understanding is that the modifierFlag "256" means that no other  
modifiers are pressed.  I haven't found it in the docs anywhere, but  
I believe that you can count on "256" meaning "no flags".  Every  
machine I've tested this on (I've done a bunch of CGEvent stuff  
recently) seems to agree.


Dave

On Jan 16, 2009, at 2:08 PM, Alexander Reichstadt wrote:


Hi,

I have a phenomenon I am exploiting but unless I know for sure why  
it works must stop to use. The objective is to make sure that while  
the mousebuttons is being pressed no other modifier key is pressed,  
if anything is pressed the whole method return. Testing for 256  
seems to work, why?


NSUInteger  modifierFlags = [currentEvent modifierFlags];
if (modifierFlags!=256) return;

Is there some documentation that supports this test, or do I have  
to check for all the different keys not to be pressed instead?


Thanks
Alex

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/lxr%40mac.com

This email sent to l...@mac.com




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: modifier-flags with no key pressed and mouseDown 256, why?

2009-01-16 Thread Michael Ash
On Fri, Jan 16, 2009 at 4:08 PM, Alexander Reichstadt  wrote:
> Hi,
>
> I have a phenomenon I am exploiting but unless I know for sure why it works
> must stop to use. The objective is to make sure that while the mousebuttons
> is being pressed no other modifier key is pressed, if anything is pressed
> the whole method return. Testing for 256 seems to work, why?
>
>NSUInteger  modifierFlags = [currentEvent modifierFlags];
>if (modifierFlags!=256) return;
>
> Is there some documentation that supports this test, or do I have to check
> for all the different keys not to be pressed instead?

Yes, there is documentation that supports it, the description of the
-modifierFlags method:

"The lower 16 bits of the modifier flags are reserved for
device-dependent bits."

In other words, the bottom 16 bits can be anything at any time. Mask
them out for this test.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: modifier-flags with no key pressed and mouseDown 256, why?

2009-01-16 Thread Dave DeLong
My understanding is that the modifierFlag "256" means that no other  
modifiers are pressed.  I haven't found it in the docs anywhere, but I  
believe that you can count on "256" meaning "no flags".  Every machine  
I've tested this on (I've done a bunch of CGEvent stuff recently)  
seems to agree.


Dave

On Jan 16, 2009, at 2:08 PM, Alexander Reichstadt wrote:


Hi,

I have a phenomenon I am exploiting but unless I know for sure why  
it works must stop to use. The objective is to make sure that while  
the mousebuttons is being pressed no other modifier key is pressed,  
if anything is pressed the whole method return. Testing for 256  
seems to work, why?


NSUInteger  modifierFlags = [currentEvent modifierFlags];
if (modifierFlags!=256) return;

Is there some documentation that supports this test, or do I have to  
check for all the different keys not to be pressed instead?


Thanks
Alex

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


modifier-flags with no key pressed and mouseDown 256, why?

2009-01-16 Thread Alexander Reichstadt

Hi,

I have a phenomenon I am exploiting but unless I know for sure why it  
works must stop to use. The objective is to make sure that while the  
mousebuttons is being pressed no other modifier key is pressed, if  
anything is pressed the whole method return. Testing for 256 seems to  
work, why?


NSUInteger  modifierFlags = [currentEvent modifierFlags];
if (modifierFlags!=256) return;

Is there some documentation that supports this test, or do I have to  
check for all the different keys not to be pressed instead?


Thanks
Alex

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com