Greetings,
Does anybody have any experience programming accessibility-enabled applications on OSX?
I’ve been trying to programmatically control the zoom functionality that’s part of Universal Access - and, so far, I’ve been unable to find any examples of how this works.
The function UAZoomChangeFocus caught my attention: https://developer.apple.com/library/mac/documentation/ApplicationServices/Reference/UniversalAccess-header-reference/Reference/reference.html
It appears that one has to zoom in with the keyboard (command, option, +) for this function to work. In my tests, the function is not changing the zoom focus, but also isn’t returning any errors.
if( UAZoomEnabled() ){
// is this thing on?
ofRectangle zoom(ofGetFrameNum()%ofGetScreenWidth(), ofGetScreenHeight()/2, 200, 150);
ofRectangle window(0, 0, ofGetScreenWidth(), ofGetScreenHeight());
zoom = convertToScreenRect(zoom);
window = convertToScreenRect(window);
printf("zoom: %f %f %f %f\n", zoom.x, zoom.y, zoom.width, zoom.height); // << endl;
CGRect cgCaretRect = CGRectMake(zoom.x, zoom.y, zoom.width, zoom.height);
CGRect cgViewRect = CGRectMake(window.x, window.y, window.width, window.height);
//OSStatus err = UAZoomChangeFocus(&cgCaretRect, NULL, kUAZoomFocusTypeInsertionPoint);
OSStatus err = UAZoomChangeFocus(&cgViewRect, &cgCaretRect, kUAZoomFocusTypeOther);
printf("zoom? %i %i\n", err == noErr, err == paramErr);
}
convertToScreenRect does the following:
//--------------------------------------------------------------
ofRectangle testApp::convertToScreenRect(ofRectangle bounds){
bounds.y = ofGetScreenHeight() - ( bounds.y + bounds.height);
return bounds;
}
I’m running this code in a ofxCocoaWindow, though I’m not sure if it’s necessary.
Perhaps this code will only work in a NSView object?
Thanks++ for any advice!
Jeremy