MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Unable to change Keyboard language programmatically even though WebView2.Focus() is used

Open
#2,071 4 comments 0 reactions 1 assignee View on GitHub

@champnic is already working on this.

Since Jan 11, 2022.

feature request tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description
Unable to change Keyboard language programmatically even though WebView2.Focus() is used

Version
SDK: 1.0.1054.31-release
Runtime: Stable 97.0.1072.55
Framework: WinForms
OS: Win10, Win7

Repro Steps
I am trying to programmaticaly change keyboard language for WebView2. This works when I use CefSharp, but I cannot succeed with WebView. Perhaps, Focus() method doesn't work fully?
I have 2 keyboard languages installed (US-English and Greek) and I am using the following code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Web.WebView2.Core;
using Microsoft.Web.WebView2.WinForms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        WebView2 browser;
        
        public Form1()
        {
            InitializeComponent();
            InitializeAsync();
        }

        public async Task InitializeAsync()
        {
            browser = new WebView2();
            browser.Dock = DockStyle.Fill;
            browser.Parent = this;
            await browser.EnsureCoreWebView2Async(null);
            browser.Source = new Uri("https://www.bing.com");
            browser.Focus();
            InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new System.Globalization.CultureInfo("el-gr"));
        }
    }
}

After I execute the app, keyboard language is still English for WebView2 (which is my system default) and not Greek. I can see that Focus() is working, because the caret is placed inside Bing's search box, but the language is still English.

AB#37717778

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.