Skip to content

Commit

Permalink
[AppKit] Add some of the missing NSAccessibility bits
Browse files Browse the repository at this point in the history
  • Loading branch information
iain holmes committed May 25, 2016
1 parent 9b24047 commit 28acf16
Show file tree
Hide file tree
Showing 2 changed files with 1,044 additions and 0 deletions.
96 changes: 96 additions & 0 deletions src/AppKit/NSAccessibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public enum NSAccessibilityUnits : nint
Picas = 4
}

[Mac (10,9)]
[Native]
public enum NSAccessibilityPriorityLevel : nint
{
Low = 10,
Medium = 50,
High = 90
}

#if !COREBUILD
public partial class NSAccessibility
{
Expand All @@ -80,6 +89,93 @@ public static CGPoint GetPointInView (NSView parentView, CGPoint point)
{
return NSAccessibilityPointInView (parentView, point);
}

[Mac (10,7)]
[DllImport (Constants.AppKitLibrary)]
static extern void NSAccessibilityPostNotificationWithUserInfo (IntPtr element, IntPtr notification, IntPtr userInfo);

public static void PostNotification (NSObject element, NSString notification, NSDictionary userInfo)
{
NSAccessibilityPostNotificationWithUserInfo (element.Handle, notification.Handle, userInfo.Handle);
}

[DllImport (Constants.AppKitLibrary)]
static extern void NSAccessibilityPostNotification (IntPtr element, IntPtr notification);

public static void PostNotification (NSObject element, NSString notification)
{
NSAccessibilityPostNotification (element.Handle, notification.Handle);
}

[DllImport (Constants.AppKitLibrary)]
static extern IntPtr NSAccessibilityRoleDescription (IntPtr role, IntPtr subrole);

public static string RoleDescription (NSString role, NSString subrole)
{
IntPtr handle = NSAccessibilityRoleDescription (role.Handle, subrole.Handle);
return NSString.FromHandle (handle);
}

[DllImport (Constants.AppKitLibrary)]
static extern IntPtr NSAccessibilityRoleDescriptionForUIElement (IntPtr element);

public static string RoleDescription (NSObject element)
{
IntPtr handle = NSAccessibilityRoleDescriptionForUIElement (element.Handle);

if (handle == IntPtr.Zero)
return null;

return NSString.FromHandle (handle);
}

[DllImport (Constants.AppKitLibrary)]
static extern IntPtr NSAccessibilityActionDescription (IntPtr action);

public static string ActionDescription (NSString action)
{
IntPtr handle = NSAccessibilityActionDescription (action.Handle);
return NSString.FromHandle (handle);
}

[DllImport (Constants.AppKitLibrary)]
static extern IntPtr NSAccessibilityUnignoredAncestor (IntPtr element);

public static NSObject UnignoredAncestor (NSObject element)
{
var handle = NSAccessibilityUnignoredAncestor (element.Handle);
return new NSObject (handle);
}

[DllImport (Constants.AppKitLibrary)]
static extern IntPtr NSAccessibilityUnignoredDescendant (IntPtr element);

public static NSObject UnignoredDescendant (NSObject element)
{
var handle = NSAccessibilityUnignoredDescendant (element.Handle);

return new NSObject (handle);
}

[DllImport (Constants.AppKitLibrary)]
static extern IntPtr NSAccessibilityUnignoredChildren (IntPtr originalChildren);

public static NSObject[] UnignoredChildren (NSArray originalChildren)
{
var handle = NSAccessibilityUnignoredChildren (originalChildren.Handle);

return NSArray.ArrayFromHandle<NSObject> (handle);
}

[DllImport (Constants.AppKitLibrary)]
static extern IntPtr NSAccessibilityUnignoredChildrenForOnlyChild (IntPtr originalChild);

public static NSObject[] UnignoredChildrenForOnlyChild (NSObject originalChild)
{
var handle = NSAccessibilityUnignoredChildrenForOnlyChild (originalChild.Handle);

return NSArray.ArrayFromHandle<NSObject> (handle);
}
}
#endif
}
Loading

0 comments on commit 28acf16

Please sign in to comment.