如何检测Mac OS上的VoiceOver是否打开?

问题描述

我正在使用MacOS应用程序,但无法弄清楚如何收听可访问性状态更改(例如,打开或关闭VoiceOver时)。

在iOS中,有一个我可以听的通知UIAccessibilityVoiceOverStatusDidChangeNotification

MacOS中是否有等同的产品?

解决方法

原来,有一个隐藏的api用于侦听辅助功能通知。您可以听module categorial1 (A : Set) where open import Data.Nat using (ℕ) open import Data.Empty open import Data.Sum open import Relation.Binary.PropositionalEquality -- type symbols data tSymb : Set where -- base : A → tSymb base : ℕ → tSymb ~ : tSymb → tSymb _\\_ : tSymb → tSymb → tSymb _//_ : tSymb → tSymb → tSymb -- A needs a decideable notion of equality isSubFormula : tSymb → tSymb → Set -- isSubFormula y (base x) = {!!} isSubFormula (base n1) (base n2) = {!Data.Nat._≟_ n1 n2 !} isSubFormula (~ t1) (base x) = ⊥ isSubFormula (t1 \\ t2) (base x) = ⊥ isSubFormula (t1 // t2) (base x) = ⊥ isSubFormula t1 (~ t2) = t1 ≡ (~ t2) ⊎ isSubFormula t1 t2 isSubFormula t1 (t2 \\ t3) = t1 ≡ (t2 \\ t3) ⊎ isSubFormula t1 t2 ⊎ isSubFormula t1 t3 isSubFormula t1 (t2 // t3) = t1 ≡ (t2 // t3) ⊎ isSubFormula t1 t2 ⊎ isSubFormula t1 t3

@"NSApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification"

然后在该方法中,您可以检查10.13中引入的voiceOverEnabled

  [center addObserver:self
             selector:@selector(onAccessibilityStatusChanged:)
                 name:@"NSApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification"
               object:nil];