-
-
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
Add OnGotFocus and OnSetFocus #341
Conversation
Currently the OnGotFocus, OnTakeFocus methods don't get called. Anyone have any thoughts? Once I can get those working I'll add the relevant event handlers so they can be handled client side. |
I suspect it could have to do with this comment: https://github.com/cefsharp/CefSharp/blob/v31.0.0-pre1/CefSharp.Wpf/WebView.cs#L713 To me it sounds that we are actually in luck that I haven't actually tried it out but if you compare it to the CefSharp1 branch it looks like it was working there. |
Let me ask a stupid question: why do we need this? Isn't the focus support (i.e. http://msdn.microsoft.com/en-US/library/system.windows.uielement.lostfocus(v=vs.110).aspx and friends) that WPF and Windows Forms already offers enough? What additional functionality do we gain by exposing the CEF API in this case? |
Also, I would personally think it would be better if you finish the #327 stuff so we can merge it... 😜 |
I was hoping that as with other browsers we'd be able to Set the focus to the address bar (something that I think would be a fairly common requirement) when OnTakeFocus is fired. I realise adding the the extra methods aren't required for that, it just made sense to me to look at finishing implementing all the methods exposed by CefFocusHandler whilst I was at it. |
@perlun I think that is a great question worth exploring. I am not 100% sure myself. How do we currently handle the case when the DOM HTMLElement.focus() is called. Shouldn't we also plum this focus event up to the WPF/WinForm control to make sure windows is aware of the focus change? |
Latest commit gets Focus working correctly in the WinForms Example |
@perlun As the Focus methods are relevant to the Does this mitigate any of your previous objections? |
@amaitland This PR would be a great feature - as we are trying to show the |
@jankurianski Maybe have a look over the code and let me know if you've got any comments? |
Also those methods aren't exposed as yet, so need to create an interface I guess. |
@amaitland If you're not in the middle of this change (as it seems it was a while ago), I'm happy to extend this further and expose a |
} | ||
} | ||
|
||
bool ClientAdapter::OnSetFocus(CefRefPtr<CefBrowser> browser, FocusSource source) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space here after browser parameter.
public enum CefFocusSource | ||
{ | ||
/// | ||
// The source is explicit navigation via the API (LoadURL(), etc). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best as <summary>
tags for the XML docs.
Help finishing this one off is most welcome! 😄 |
https://github.com/numbersint/CefSharp/compare/feature/focus-handler-ext
@amaitland I couldn't figure out how to make a clean PR for your fork, as git seems to want to include every |
Add CefFocusSource enum for mapping from cef_focus_source_t enum
…d only call them in the context of the WinForms ChromiumWebBrowser
a2debed
to
5b56436
Compare
@jankurianski I've just I'm happy if you want to cherry pick my changes and create a new PR. Whatever is easiest. |
Any thoughts on how we can preserve the current default behavior of the void IWebBrowserInternal.OnTakeFocus(bool next)
{
SelectNextControl(this, next, true, true, true);
} |
Closing in favor of #639 |
Add OnGotFocus and OnSetFocus
Add CefFocusSource enum for mapping from cef_focus_source_t enum