如何检测用户是否启用了Mac OS高对比度可访问性设置? [英] How do I detect if a user has Mac OS high contrast accessibility settings enabled?

查看:215
本文介绍了如何检测用户是否启用了Mac OS高对比度可访问性设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个React/TypeScript项目,我试图检测用户是否启用了Mac OS的任何高对比度可访问性设置:反转颜色,使用灰度,区分不带颜色,增加对比度或增加显示对比度设置.

I have a React/TypeScript project, and I am trying to detect if a user has any of Mac OS's high contrast accessibility settings enabled: Invert colors, Use grayscale, Differentiate without color, Increase contrast, or an increased Display contrast setting.

我想使用JavaScript/TypeScript进行检测.

I want to detect these using JavaScript/TypeScript.

到目前为止,我只能检测到反转颜色.

So far, I can detect only Invert colors.


如何检测用户是否启用了其他任何Mac OS辅助功能设置?


更多信息:

  • The prefers contrast media query is not yet available. I tried it anyway, and it doesn't work.
  • The inverted colors media query tests only for the Invert colors setting.
  • Apple's dev docs on color and contrast do not have a solution.
  • Detecting high contrast use in other browser, OS scenarios

推荐答案

目前恐怕不可能.

从10.9开始,Objective-C中用于确定是否可访问性模式处于活动状态的功能(布尔AXAPIEnabled(void);)已被弃用,没有任何迹象表明存在替代项.您可以在Apple Developer网站上看到它.通过扩展,如果该系统级别的开发人员不再具有访问权限,我希望Web开发人员也将受到限制(就像AppleScript编写者似乎没有访问权限一样).

The feature in Objective-C to determine if the accessibility mode is active (boolean AXAPIEnabled(void);) has been deprecated as of 10.9 with no indication that there is a replacement. You can see it on the Apple Developer site. By extension, if developers at that level of the system no longer have access, I expect web developers would also be restricted (just as AppleScript writers seem to not have access).

通常,最需要辅助技术的用户都不愿意测试辅助技术的存在或辅助功能的激活.这会带来非常现实的风险,即好主意的开发人员可能会破坏这些功能(可能是通过取消翻页),还可能使不良行为者确定某人的个人健康信息.

In general, testing for the presence of assistive technology or activation of assistive features is frowned upon by the users who need it most. It creates the very real risk of both well-intentioned developers breaking these features (perhaps by un-verting the page) and also of allowing bad actors to determine somebody's personal health information.

在将来可能会出现在第5阶段(建议) https://drafts.c​​sswg.org/mediaqueries-5/#prefers-contrast

Altought it might come in future as its in stage 5 (proposal) https://drafts.csswg.org/mediaqueries-5/#prefers-contrast

除此之外,恐怕您正面临死胡同.

Other than that Iam afraid you are facing dead end.

这篇关于如何检测用户是否启用了Mac OS高对比度可访问性设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆