-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard input doesn't work when Browser is hosted in WPF Popup. #1590
Comments
I have removed the link to your https://github.com/cefsharp/CefSharp/blob/master/CONTRIBUTING.md#help-us-help-you When posting code, either fork the https://github.com/cefsharp/CefSharp.MinimalExample You'll have to debug this one yourself if it's important to you. The low level source hook for the keyboard handling mustn't be called correctly when hosted in a I'd suggest you use a |
We use an onscreen keyboard and I found there were problems with focus and input like you have described (we use winforms but I think the same problem could occur in wpf too). If the browser is hosted in another control - say a Panel - focusing the panel won't necessarily focus the browser. I found that when I focused the hosting control I also needed to call the Focus() method on the CefSharp browser. After your secondary window finishes loading try focusing the browser control. |
I moved my code at https://github.com/SiddharthMishraPersonal/CefSharpWithPopup In our application we are using Telerik RadPane Control. We raised a ticket to Telerik for the same issue and found that the AutoHide and AutoShow feature of RadPane is not only but the Popup control. Hence, we tried to test it with simple Popup control and it is reproducible. I have downloaded latest CefSharp code and built it. Used the build binaries and tried to debug the issue. While debugging we found that that event "PresentationSourceChangedHandler()" is not getting fired, if we are using Popup control to host Cef browser. The method is at line no 846 in file ChromiumWebBrowser.cs under CefSharp.Wpf project. As per current situation, we cannot get rid of RadPane, so, we have to fix Popup related issue to move on. |
Thanks 👍 Probably best to remove the binaries though 😄
Yep, that's pretty much what I was expecting.
Linking to the file directly e.g. https://github.com/cefsharp/CefSharp/blob/cefsharp/49/CefSharp.Wpf/ChromiumWebBrowser.cs#L844 is much easier for others to follow then just providing a link number.
Two options that I can think of
https://msdn.microsoft.com/en-us/library/system.windows.presentationsource.fromvisual%28v=vs.110%29.aspx Next version will have In the current version there is only a version that wraps the underlying https://github.com/cefsharp/CefSharp/blob/cefsharp/47/CefSharp/IBrowserHost.cs#L130 |
For 41.0.0 version I found the resolution of this issue here. But, we found that the method is not available in later versions of CefSharp.Wpf. |
As I've already said, the next version will have that option. For now you may need to make some changes and build the source yourself. |
I downloaded latest 47.0.3.0 from NuGet but the method SendKey() is missing. Am I missing anything or it is going to release in another version? |
|
Thinking about this again, you can use the current release version as Would look something like this: var window = Window.GetWindow(this);
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(window).Handle);
source.AddHook(new HwndSourceHook(SourceHook)); |
Or something like HwndSource source = (HwndSource)HwndSource.FromVisual(this);
source.AddHook(new HwndSourceHook(SourceHook)); |
|
Hi @amaitland I am facing the same issue. Need your help on this. |
A simple Please would be nice
Read my comments again, it's not called |
Hey I am sorry to keep bothering you on this man. I have been working on this issue for last two days and tried going through thread and the other one which also has similar issue but I couldnt solve. So finally I have come to you. Can you please help me get over this hurdle? I am not sure if I am seraching it correctly. It should be WebBroswer.SendKey() right? |
It's
Incorrect. Read over my notes carefully. |
I guess i got it. IbrowserHost.SendKeyEvent. Thanks alot... |
Hey when you see my message tomorrow can you please give a little advice on when should I call IBrowserHost.SendKeyEvent(). I tried calling this inside OnGotKeyboardFocus(). But it did not work. |
Use the other suggestion, sub class and attach the
Not sure how keyboard focus relates to a key press? |
Also I don't have time to write this for you, I'm confident there is enough information provided that you can figure this out on your own. |
Hey thank you for your response. I just found a fix for this. Actually am using the browser control inside a grid which is enclosed within a scrollViewer control. So what i did is, I jus made focussable for the ScrollViewer to false and it started working. I am able to enter values in to the textboxes within browser. Although am not sure why the focus is automatically moving to scrollviewer when am trying to focus within the browser. |
Did you search the issue tracker??? An issue already exists for that problem see #1002 |
No I did not see that thread before. thing is I just explored the application and found that they are having a generic control which has a scrollviewer and all other xamls are enclosed within that. I just kind of guessed that setting focussable false for scroll might fix and it worked. anyway now i found other workarounds in below thread. Thanks so much!!! really appreciate your effort and response. |
Your link is malformed.
I'll be honest, interacting with you is a very frustrating experience. I feel that you've unnecessarily wasted quite a bit of my time in the last week. This is my personal time, nobody is paying me to answer questions! If you continue to ask questions without demonstrating a reasonable amount of effort, I will ignore you, just so you know! Research before posting 👍 |
Dude.. I know you got frustrated. I researched as much as I could in the last 2 days. when I do not know the root cause of the issue It is really difficult to look for a specific solution. In this case, I didnt know there is a scroll viewer control in the application and its impact on webbrowser. I understand your point, spending your free time on this. I really do not have words. And sorry again for bothering you!! |
I've though about this more, and before I'll help you again you'd need to contribute something to the project, implement a feature request, improve the |
We have hosted CefSharp (version: 47.0.2.0) browser in a WPF Popup control. Once our webpage loads and we try to enter something in textbox (html input tag), which doesn't work.
Please find dummy project example to reproduce the issue. Please use latest CefSharp binaries. (I removed "bin/debug" folder as it was getting too big to attach.
For this example we have used google search page to reproduce the issue.
Reproducing steps:
**Expected: _User should be able to enter search keywords.
_Actual: Cannot type single character.
Please provide me any inputs on this.
The text was updated successfully, but these errors were encountered: