프로그래밍/Xamarin(자마린)

[Xamarin, c#, UWP] UWP, How to Disable Caret Browsing in code(key F7), Disable Cursor Browsing in uwp app

그래도동 2022. 10. 11. 16:07
728x90
반응형
SMALL

 

uwp 앱에서 코딩을 하지않아도 F7 키를 누르면 위와 같은 메시지가 뜬다.

앱 내에서 keydown , keyup 이벤트를 써도 메시지가 뜬다.

하지만

Window.Current.Dispatcher.AcceleratorKeyActivated 이벤트를 받아서 handled = true로 해주면

메시지가 뜨기전에 키보드를 잡을 수 있다.

 

If you press F7 even if you do not code in the uwp app, the above message appears.
Even if you use keydown and keyup events within the app, a message appears.
but
If you receive the Window.Current.Dispatcher.AcceleratorKeyActivated event and set it to "handled = true",
You can hook the keyboard before the message pop up.

 

 public MainPage()
{
    this.InitializeComponent();

    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
	// this ☆★
    Window.Current.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;

    // Load App
    LoadApplication(new BK.KDS.App());
}

 private void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
    // Hook F7 Key (Disable Caret Browsing)
    if (args.VirtualKey == Windows.System.VirtualKey.F7)
    {
        args.Handled = true;
    }
}

참고

 - https://stackoverflow.com/a/45789573

 

728x90
반응형
LIST