Skip to content
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

Clicking on Control using Winforms does not Set Focus #570

Closed
RadicalLinux opened this issue Nov 4, 2014 · 10 comments · Fixed by #632
Closed

Clicking on Control using Winforms does not Set Focus #570

RadicalLinux opened this issue Nov 4, 2014 · 10 comments · Fixed by #632

Comments

@RadicalLinux
Copy link
Contributor

When using docking tabs menus etc. that should automatically close when they no longer have focus, clicking on the browser does not fire the event needed. You can duplicate the issue by running the winforms example. After the browser is fully loaded click on the edit menu. Now click back on the browser. The edit menu will not close like it should. Also the mouse events are not triggered.

BTW All the other issues have been resolved! Great Work!

@amaitland
Copy link
Member

Not all the Focus event handlers have been implemented, there's a very old PR that I created here #341

Feel free to take it for a spin.

@RadicalLinux
Copy link
Contributor Author

Okay I've implemented the code changes from #341 and I've found that OnGotFocus() from your code does get called, but it doesn't look like any handler was implemented. Am I right in saying that? At current time it appears that it doesn't do anything, so I've been playing with it, but so far coming up way short.

@jankurianski
Copy link
Member

@RadicalLinux Not sure if it helps you any more, but I found a hack to make this work for my case. If you paste this into BrowserTabUserControl.cs in the WinForms example project then the ToolStrip will get dismissed when you click into the browser:

https://gist.github.com/jankurianski/2163d7928d3d6f839e47

@RadicalLinux
Copy link
Contributor Author

Thanks, I'm giving it a try now.

@florianknecht
Copy link

Hey guys, thanks for the great workaround. Almost got it working for me.. almost. My problem is that the workaround is causing Chromium to lose focus for a short time. This destroys functionality in my app because as a graphics editor it relies heavily on mouse event handling.Any ideas on how to fix this?

@jankurianski
Copy link
Member

jankurianski commented Jul 21, 2015 via email

@florianknecht
Copy link

This is it! Thank you so much. When posting WM_NCLBUTTONDOWN (0x00A1), cef doesn't lose focus and handles the following mouse click correctly.

@amaitland
Copy link
Member

@jankurianski Is it worth adding your Gist example to the WinForms.Example project? Seems like there's enough interest.

@jankurianski
Copy link
Member

This is it! Thank you so much. When posting WM_NCLBUTTONDOWN (0x00A1), cef doesn't lose focus and handles the following mouse click correctly.

@asdorius No, thank you. 👍 I had a bug in my app when running on VMs where the mouseup never got sent to CefSharp, and WM_LBUTTONDOWN was the cause of the problem.

I've updated my Gist and the WinForms.Example PR to use WM_NCLBUTTONDOWN now.

@jankurianski
Copy link
Member

@jankurianski Is it worth adding your Gist example to the WinForms.Example project? Seems like there's enough interest.

Good idea. It's too hacky to be built-in to the ChromiumWebBrowser class, but putting it in WinForms.Example makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants