mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
7eafe6211c
Reverted changes from 77b433bb69 and
instead exposed SendKeyEvent in the ChromiumWebBrowser to be able to
move the handler for OnPreviewTextInput to the WPF example.
50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using CefSharp.Example;
|
|
|
|
namespace CefSharp.Wpf.Example.Views
|
|
{
|
|
public partial class BrowserTabView : UserControl
|
|
{
|
|
public BrowserTabView()
|
|
{
|
|
InitializeComponent();
|
|
|
|
browser.RequestHandler = new RequestHandler();
|
|
browser.RegisterJsObject("bound", new BoundObject());
|
|
|
|
browser.MenuHandler = new Handlers.MenuHandler();
|
|
browser.GeolocationHandler = new Handlers.GeolocationHandler();
|
|
browser.DownloadHandler = new DownloadHandler();
|
|
browser.PreviewTextInput += (o, e) =>
|
|
{
|
|
foreach (var character in e.Text)
|
|
{
|
|
browser.SendKeyEvent((int)WM.CHAR, character, 0);
|
|
}
|
|
|
|
e.Handled = true;
|
|
};
|
|
|
|
CefExample.RegisterTestResources(browser);
|
|
}
|
|
|
|
private void OnTextBoxGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
|
|
{
|
|
var textBox = (TextBox)sender;
|
|
textBox.SelectAll();
|
|
}
|
|
|
|
private void OnTextBoxGotMouseCapture(object sender, MouseEventArgs e)
|
|
{
|
|
var textBox = (TextBox)sender;
|
|
textBox.SelectAll();
|
|
}
|
|
|
|
}
|
|
}
|