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

查看:36
本文介绍了如何检测用户是否启用了 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

推荐答案

恐怕目前不可能.

Objective-C 中用于确定可访问性模式是否处于活动状态的功能 (boolean AXAPIEnabled(void);) 已从 10.9 开始弃用,没有迹象表明有替代品.您可以在 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天全站免登陆