-
-
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
Implement Focused property #632
Conversation
I remembered there's a post in the google groups that I'd been meaning to do something about https://groups.google.com/forum/#!topic/cefsharp/myTd5OCjb5E It relates to Thoughts on implementing |
I probably should have also made mention of http://magpcss.org/ceforum/apidocs3/projects/%28default%29/CefFocusHandler.html I think we can come up with a more elegant solution. Quite a while ago I looked at implementing |
@amaitland, I tried to force the
So I still think this PR is necessary. |
@sylvain-hamel I was thinking with |
I think the fix I proposed is better beause it fixes the problem in the core and does not force users to define a handler and to figure out how to handle the events. After all who wouldn't want Focus to retunr the right value? |
Plan was to implement the default behavior in |
Hi guys, I am currently working on a PR to implement something like what @amaitland is suggesting. (I feel a bit guilty about adding the FocusHandler but not addressing this core issue.) I think it will turn out a bit cleaner because we won't have to rely on the Win32 APIs. |
@jankurianski Awesome thanks! I'll hold off on making any changes 👍 |
It turns out that it isn't possible to implement the You can see what I tried here: https://github.com/numbersint/CefSharp/compare/fixes/winforms-focused-property I implement the When I try the steps in the first post, the The reason for this is that
It would only be possible to implement the For now, I think the solution of @sylvain-hamel here is the only way to go. |
@jankurianski Appreciate you taking the time to have a look. I guess short term the fix we have is workable. Strange that focus events aren't called. So let's go with this fix for now. |
|
||
namespace CefSharp.Internals | ||
{ | ||
public static class User32 |
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.
Can we move this class into CefSharp.WinForms
? it's unlikely to be used in any of the other projects.
Merged. I'm still hopeful that at some point we can get |
Issue:
ChromiumWebBrowser.Focused
is alwaysfalse
Cause : cef does not implement focused correctly (seems related to https://code.google.com/p/chromiumembedded/issues/detail?id=563)
Fix : Manually implement Focused
How to test:
MessageBox.Show(((Control)Browser).Focused.ToString())
.I think this should fix #570. However if it does not, then this fix is still relevant to any code that relies on the
Focused
property. I did not test the WPF side of this at all.Background: We've been running with this fix for a while now (before we started contributing to this project). I recalled this fix while reading #570 so here is the PR (I'll be able to remove this from our custom ChromiumWebBrowser derived class too).