Mouse Button Pressed with the GUI Toolkit

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

Mouse Button Pressed with the GUI Toolkit

Postby teremy » Sun Nov 27, 2016 1:21 pm

Hello.
I did some stuff with javascript but you can't get the mouse position with JS, when it is out of the window. The same goes for mouse button events.
It's not a problem that I'm not able todo this with JS, since I should be able todo it with the GUI Toolkit, right?
I am currently using cefglue with GTK#, although I could also use WinForms, since I am not using anything other than the browser window ( no menus, buttons or other gui elements ).
I am not quite sure how to catch mouse events with GTK#.
I tried to catch key events like this ( thought if I get this to work, I should be able to work with mouse events too ):
In the GTK Window I put this:
Code: Select all
KeyPressEvent += KeyPressHandler;

And the corresponding method KeyPressHandler.
But the method is never called.
I am using the MultiThreadedMessageLoop, so I don't have direct access to the message loop.
Do I have to quit using the MultiThreadedMessageLoop and do my own message loop?
The GTK#'s message loop is also happening internally since
Code: Select all
Application.Run();
doesn't let me see anything that is happening there.
So how am I able to see if a mouse button is pressed ( outside of the window ) ?
teremy
Techie
 
Posts: 15
Joined: Mon Aug 22, 2016 8:51 am

Re: Mouse Button Pressed with the GUI Toolkit

Postby fddima » Wed Nov 30, 2016 11:50 am

Why you are use GTK# on Windows?!

On Windows (or on any "old" native windows framework?) there is no event bubbling like in tree-based frameworks (html/wpf), so everything should be handled exactly in corresponded window. Or handle message for all windows, but this requires custom message loop.

From you message, i'm can't understand your problem: don't mix WinForms and GTK# (why you need this?), and you handle mouse/keyboard input in wrong place (in window which doesn't actually receive input).

Use corresponding CEF handlers to handle input inside browser (and avoid perform this on window level - anyway without hacks you can't do it). If you try handle KeyPressEvent event on browser control - then you should understand that this control (i mean browser winforms or gtk control) just wraps browser in control, but it naver exposes normal UI toolkit events: there is just no have place for them.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 18 guests