-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,15 +333,15 @@ void CefBrowserHostWrapper::ImeSetComposition(String^ text, cli::array<Compositi | |
} | ||
|
||
//Replacement Range is Mac OSX only | ||
_browserHost->ImeSetComposition(StringUtils::ToNative(text), underlinesVector, CefRange(), range); | ||
_browserHost->ImeSetComposition(StringUtils::ToNative(text), underlinesVector, CefRange(UINT32_MAX, UINT32_MAX), range); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Antonyo
Author
Owner
|
||
} | ||
|
||
void CefBrowserHostWrapper::ImeCommitText(String^ text) | ||
{ | ||
ThrowIfDisposed(); | ||
|
||
//Range and cursor position are Mac OSX only | ||
_browserHost->ImeCommitText(StringUtils::ToNative(text), CefRange(), NULL); | ||
_browserHost->ImeCommitText(StringUtils::ToNative(text), CefRange(UINT32_MAX, UINT32_MAX), NULL); | ||
} | ||
|
||
void CefBrowserHostWrapper::ImeFinishComposingText(bool keepSelection) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using CefSharp.Structs; | ||
using CefSharp.Wpf.Example.Handlers; | ||
|
||
namespace CefSharp.Wpf.Example.Controls | ||
{ | ||
public class ChromiumWebBrowserIMESupport : ChromiumWebBrowser | ||
{ | ||
public ChromiumWebBrowserIMESupport() | ||
{ | ||
WpfKeyboardHandler = new IMEWpfKeyboardHandler(this); | ||
} | ||
|
||
static ChromiumWebBrowserIMESupport() | ||
{ | ||
InputMethod.IsInputMethodEnabledProperty.OverrideMetadata( | ||
typeof(ChromiumWebBrowserIMESupport), | ||
new FrameworkPropertyMetadata( | ||
true, | ||
FrameworkPropertyMetadataOptions.Inherits, | ||
(obj, e) => | ||
{ | ||
var browser = obj as ChromiumWebBrowserIMESupport; | ||
if ((bool)e.NewValue && browser.GetBrowserHost() != null && Keyboard.FocusedElement == browser) | ||
{ | ||
browser.GetBrowserHost().SendFocusEvent(true); | ||
InputMethod.SetIsInputMethodSuspended(browser, true); | ||
} | ||
})); | ||
|
||
InputMethod.IsInputMethodSuspendedProperty.OverrideMetadata( | ||
typeof(ChromiumWebBrowserIMESupport), | ||
new FrameworkPropertyMetadata( | ||
true, | ||
FrameworkPropertyMetadataOptions.Inherits)); | ||
} | ||
|
||
protected override void OnImeCompositionRangeChanged(Range selectedRange, Structs.Rect[] characterBounds) | ||
{ | ||
var imeKeyboardHandler = WpfKeyboardHandler as IMEWpfKeyboardHandler; | ||
if (imeKeyboardHandler.IsActive) | ||
{ | ||
var screenInfo = GetScreenInfo(); | ||
var scaleFactor = screenInfo.HasValue ? screenInfo.Value.DeviceScaleFactor : 1.0f; | ||
|
||
UiThreadRunSync(() => | ||
{ | ||
var parentWindow = GetParentWindow(); | ||
if (parentWindow != null) | ||
{ | ||
var point = TransformToAncestor(parentWindow).Transform(new System.Windows.Point(0, 0)); | ||
var rects = new List<Structs.Rect>(); | ||
|
||
foreach (var item in characterBounds) | ||
rects.Add(new Structs.Rect( | ||
(int)((point.X + item.X) * scaleFactor), | ||
(int)((point.Y + item.Y) * scaleFactor), | ||
(int)(item.Width * scaleFactor), | ||
(int)(item.Height * scaleFactor))); | ||
|
||
imeKeyboardHandler.ChangeCompositionRange(selectedRange, rects); | ||
} | ||
}); | ||
} | ||
|
||
Visual GetParentWindow() | ||
{ | ||
var current = VisualTreeHelper.GetParent(this); | ||
while (current != null && !(current is Window)) | ||
current = VisualTreeHelper.GetParent(current); | ||
|
||
return current as Window; | ||
} | ||
} | ||
} | ||
} |
@Antonyo The documentation says replacement range is only used on
Mac
, what difference does passing in max to a value that should be ignored make?