Ekran okuyucular ve donanım sistemi düğmeleri

Ekran Okuyucusugibi ekran okuyucuların donanım sistemi düğme olaylarını tanıyıp işleyebilmesi ve durumlarını kullanıcılara iletebilmesi gerekir. Bazı durumlarda, ekran okuyucunun bu donanım düğmesi olaylarını yalnızca kendisinin işlemesi ve bu olayların diğer işleyicilere iletilmesine izin vermemesi gerekebilir.

Fn donanım sistemi düğmesi olaylarını diğer donanım düğmeleriyle aynı şekilde dinlemek ve işlemek için Windows SDK'sının Windows.UI.Input ad alanında SystemButtonEventController'ı kullanın.

WinUI 3 / Windows Uygulama SDK'sı uygulamaları için bu API, winrt::Windows::UI::Input yerine halen Windows ad alanından (Microsoft.UI.*) tüketilir.

Uyarı

Fn düğmesi desteği OEM'e özgüdür ve ilgili kilit göstergesi ışığıyla birlikte (görme engelli veya görme bozukluğu olan kullanıcılar için yararlı olmayabilir) açma/kapatma özelliği (basılı tutma tuş bileşimine karşı) gibi özellikler içerebilir.

Fn düğmesi olayları, Windows.UI.Input ad alanında SystemButtonEventController aracılığıyla kullanıma sunulur. SystemButtonEventController nesnesi aşağıdaki olayları destekler:

Önemli

SystemButtonEventController, daha yüksek öncelikli bir işleyici tarafından zaten işlenmişse bu olayları alamaz.

Örnekler

Aşağıdaki örneklerde DispatcherQueue tabanlı bir SystemButtonEventController oluşturmayı ve bu nesne tarafından desteklenen dört olayı işlemeyi gösteririz.

Fn düğmesine basıldığında desteklenen olaylardan birden fazlasının tetiklenmesi yaygındır. Örneğin, Surface klavyesinde Fn düğmesine basıldığında SystemFunctionButtonPressed, SystemFunctionLockChanged ve SystemFunctionLockIndicatorChanged aynı anda tetikler.

  1. Bu ilk kod parçacığında, yalnızca gerekli ad alanlarını dahil ediyoruz ve bazı genel nesneleri, DispatcherQueue ve DispatcherQueueController nesneleri de dahil olmak üzere, SystemButtonEventController iş parçacığını yönetmek için belirtiyoruz.

    Ardından, olay belirteçlerinin, SystemButtonEventController olay işleme temsilcileri kaydedildiğinde döndürüleceğini belirtiyoruz.

    namespace winrt
    {
        using namespace Windows::System;
        using namespace Windows::UI::Input;
    }
    
    ...
    
    // Declare related members
    winrt::DispatcherQueueController _queueController;
    winrt::DispatcherQueue _queue;
    winrt::SystemButtonEventController _controller;
    winrt::event_token _fnKeyDownToken;
    winrt::event_token _fnKeyUpToken;
    winrt::event_token _fnLockToken;
    
  2. Ayrıca systemFunctionLockIndicatorChanged olayı için bir olay belirteci ve uygulamanın "Öğrenme Modu" içinde olup olmadığını (kullanıcının herhangi bir işlev gerçekleştirmeden yalnızca klavyeyi keşfetmeye çalıştığı) belirten bir bool belirteceğiz.

    winrt::event_token _fnLockIndicatorToken;
    bool _isLearningMode = false;
    
  3. Bu üçüncü kod parçacığı, SystemButtonEventController nesnesi tarafından desteklenen her olay için karşılık gelen olay işleyicisi temsilcilerini içerir.

    Her olay işleyicisi, gerçekleşen olayı duyurur. Buna ek olarak, SystemFunctionLockIndicatorChanged işleyicisi de uygulamanın "Öğrenme" modunda_isLearningMode ( = true) olup olmadığını denetler. Bu da olayın diğer işleyicilere kaynamasını önler ve kullanıcının eylemi gerçekleştirmeden klavye özelliklerini keşfetmesine olanak tanır.

    void SetupSystemButtonEventController()
    {
        // Create dispatcher queue controller and dispatcher queue
        _queueController = winrt::DispatcherQueueController::CreateOnDedicatedThread();
        _queue = _queueController.DispatcherQueue();
    
        // Create controller based on new created dispatcher queue
        _controller = winrt::SystemButtonEventController::CreateForDispatcherQueue(_queue);
    
        // Add Event Handler for each different event
        _fnKeyDownToken = _controller->SystemFunctionButtonPressed(
            [](const winrt::SystemButtonEventController& /*sender*/, const winrt:: SystemFunctionButtonEventArgs& args)
            {
                // Mock function to read the sentence "Fn button is pressed"
                PronounceFunctionButtonPressedMock();
                // Set Handled as true means this event is consumed by this controller
                // no more targets will receive this event
                args.Handled(true);
            });
    
            _fnKeyUpToken = _controller->SystemFunctionButtonReleased(
                [](const winrt::SystemButtonEventController& /*sender*/, const winrt:: SystemFunctionButtonEventArgs& args)
                {
                    // Mock function to read the sentence "Fn button is up"
                    PronounceFunctionButtonReleasedMock();
                    // Set Handled as true means this event is consumed by this controller
                    // no more targets will receive this event
                    args.Handled(true);
                });
    
        _fnLockToken = _controller->SystemFunctionLockChanged(
            [](const winrt::SystemButtonEventController& /*sender*/, const winrt:: SystemFunctionLockChangedEventArgs& args)
            {
                // Mock function to read the sentence "Fn shift is locked/unlocked"
                PronounceFunctionLockMock(args.IsLocked());
                // Set Handled as true means this event is consumed by this controller
                // no more targets will receive this event
                args.Handled(true);
            });
    
        _fnLockIndicatorToken = _controller->SystemFunctionLockIndicatorChanged(
            [](const winrt::SystemButtonEventController& /*sender*/, const winrt:: SystemFunctionLockIndicatorChangedEventArgs& args)
            {
                // Mock function to read the sentence "Fn lock indicator is on/off"
                PronounceFunctionLockIndicatorMock(args.IsIndicatorOn());
                // In learning mode, the user is exploring the keyboard. They expect the program
                // to announce what the key they just pressed WOULD HAVE DONE, without actually
                // doing it. Therefore, handle the event when in learning mode so the key is ignored
                // by the system.
                args.Handled(_isLearningMode);
            });
    }
    

Ayrıca bakınız

SystemButtonEventController Sınıfı