dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.06k stars 1.17k forks source link

The TextBox process IME input with delay in Korean #4315

Open alexdi220 opened 3 years ago

alexdi220 commented 3 years ago
alexdi220 commented 3 years ago

Can I get any workaround which we can use in our code to resolve the issue on our side?

lindexi commented 3 years ago

@alexdi220 Could you try the code:

[DllImport("User32.dll")]
public static extern IntPtr SetFocus(IntPtr hWnd);

IntPtr GetHwnd(Popup popup)
{
    HwndSource source = (HwndSource)PresentationSource.FromVisual(popup.Child);
    return source.Handle;
}

private void ShowPopupButtonClick(object sender, RoutedEventArgs e)
{
    ThePopup.IsOpen = true;
    IntPtr handle = GetHwnd(ThePopup);
    SetFocus(handle);
}

You should call the ShowPopupButtonClick method when you want to show the popup.

The other way is to call the SetForegroundWindow method:

[DllImport("USER32.DLL")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);

public static void ActivatePopup(Popup popup)
{
    HwndSource source = (HwndSource)PresentationSource.FromVisual(popup.Child);
    IntPtr handle = source.Handle;

    SetForegroundWindow(handle);
}
alexdi220 commented 3 years ago

@lindexi Great, thank you for a quick answer. Your workarounds are well but we can't use them directly in our components. But we can advise it for our customers. So still waiting for a fix.

alexdi220 commented 2 years ago

Do you have any plans to fix that issue? Our Korean and Japanese customers facing this at time

pchaurasia14 commented 2 years ago

@alexdi220 - Does it still happen for .NET 6 ?

alexdi220 commented 2 years ago

@alexdi220 - Does it still happen for .NET 6 ?

Apologize, for the misunderstanding. I really don't mean the input delay but the placement of the IME editor - it doesn't open near the TextBox image

DmitryRomenskiy commented 2 years ago

@pchaurasia14

Hi,

Can you please share something about your plans for the issue? Do you need more details?

pchaurasia14 commented 2 years ago

@DmitryRomenskiy - This is currently under investigation. We found out that the editor that is opened is tied to OS and it may be opening on the top left corner when it doesn't find the parent control handle.

We'll update this thread once we confirm the behavior and its fix.