Re: kAXPositionAttribute and kAXSizeAttribute
Re: kAXPositionAttribute and kAXSizeAttribute
- Subject: Re: kAXPositionAttribute and kAXSizeAttribute
- From: spiderlama <email@hidden>
- Date: Thu, 19 Jul 2007 20:03:52 +1000
It seems I neglected to change the values returned from the
functions. I have fixed it now. Instead of this...
- (void) doSomething {
NSRect rect; // dock rect
AXUIElementCopyAttributeValue(dock, kAXPositionAttribute,
(CFTypeRef *)&rect.origin);
AXUIElementCopyAttributeValue(dock, kAXSizeAttribute, (CFTypeRef *)
&rect.size);
NSLog(@"Position: (%f, %f)", rect.origin.x, rect.origin.y);
NSLog(@"Size: %f x %f", rect.size.width, rect.size.height);
}
...it should be this...
- (void) doSomething {
AXValueRef value;
NSRect rect; // dock rect
// get size
AXUIElementCopyAttributeValue(dock, kAXSizeAttribute, (CFTypeRef *)
&value);
AXValueGetValue(value, kAXValueCGSizeType, (void *) &rect.size);
// get position
AXUIElementCopyAttributeValue(dock, kAXPositionAttribute, (CFTypeRef
*) &value);
AXValueGetValue(value, kAXValueCGPointType, (void *) &rect.origin);
// window rect's are flipped-y
rect.origin.y = [[NSScreen mainScreen] frame].size.height -
rect.origin.y - rect.size.height;
NSLog(@"Position: (%f, %f)", rect.origin.x, rect.origin.y);
NSLog(@"Size: %f x %f", rect.size.width, rect.size.height);
}
This now gives me output:
2007-07-19 20:01:57.605 Listener[5861] Position: (163.000000, 0.000000)
2007-07-19 20:01:57.607 Listener[5861] Size: 698.000000 x 43.000000
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden