ImeSharp 1.4.0
dotnet add package ImeSharp --version 1.4.0
NuGet\Install-Package ImeSharp -Version 1.4.0
<PackageReference Include="ImeSharp" Version="1.4.0" />
paket add ImeSharp --version 1.4.0
#r "nuget: ImeSharp, 1.4.0"
// Install ImeSharp as a Cake Addin #addin nuget:?package=ImeSharp&version=1.4.0 // Install ImeSharp as a Cake Tool #tool nuget:?package=ImeSharp&version=1.4.0
IME Sharp
A C# wrapper for Windows IME APIs. Its goal is to support both IMM32 and TSF.
TSF Implementation is based on WPF core.
Packages
dotnet add package ImeSharp
Note ImeSharp.NetStandard package is deprecated, use ImeSharp instead.
Usage
Initialization
Call InputMethod.Initialize
to initialize the input method with a window handle, e.g. InputMethod.Initialize(someWindowHandle)
.
If you don't want the OS Candidate Window, do InputMethod.Initialize(someWindowHandle, false)
.
Custom message pumping
If we don't enable custom windows message pumping. Use TSF in WinForms would have a issue: Frame will randomly stuck when composing with IME. This is because TSF disables Application.Idle event when it's busy. Enables custom message pumping fix this.
In WinForms, we add message pumping at the end line in Application.Idle
handler, e.g.:
private void Application_Idle(object sender, EventArgs e)
{
Game.Tick();
// Enables custom message pumping
InputMethod.PumpMessage();
}
Hook events
InputMethod.TextInputCallback = OnTextInput;
InputMethod.TextCompositionCallback = OnTextComposition;
Retrieve other composition info from InputMethod.CandidateList
and other fields for CJK IMEs.
Set position of OS rendered IME Candidate Window
InputMethod.SetTextInputRect(location.X, location.Y, 0, textBoxHeight);
Test IMM32 implementation only
IMM32 would be only enabled if TSF service is not available.
You can return false
manually in TextServicesLoader.ServicesInstalled
to mimic TSF unavailable case.
TODO
- Make it work in Unity3d
MS Docs
Other samples / implementations
Credits
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- Microsoft.Win32.Registry (>= 5.0.0)
- TsfSharp (>= 1.1.0)
-
.NETFramework 4.6
- Microsoft.Win32.Registry (>= 5.0.0)
- TsfSharp (>= 1.1.0)
-
.NETStandard 2.0
- Microsoft.Win32.Registry (>= 5.0.0)
- TsfSharp (>= 1.1.0)
-
net7.0
- Microsoft.Win32.Registry (>= 5.0.0)
- TsfSharp (>= 1.1.0)
-
net8.0
- Microsoft.Win32.Registry (>= 5.0.0)
- TsfSharp (>= 1.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ImeSharp:
Package | Downloads |
---|---|
FNA.NET
Fork of FNA with nuget packages. |
GitHub repositories
This package is not used by any popular GitHub repositories.