Results 1 to 7 of 7

Thread: Handling mouse events in Qt WebKit

  1. #1
    Join Date
    Dec 2007
    Posts
    27
    Thanks
    1
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Handling mouse events in Qt WebKit

    Hi,
    in an application I use QtWebKit to show flash contents. If you press the right mouse button over a Adobe flash movie, the flash settings menu will appear.
    Is there a way to catch and drop or delegate this mouse event so that this menu will not be displayed anymore?
    Any ideas?
    Thanks Yakin

  2. #2
    Join Date
    Aug 2009
    Posts
    11
    Thanks
    1

    Default Re: Handling mouse events in Qt WebKit

    You should call Adobe to solve this problem.

  3. #3
    Join Date
    Dec 2007
    Posts
    27
    Thanks
    1
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Handling mouse events in Qt WebKit

    No, that would not lead to a solution at all.
    Let me reword my question:
    Is it possible for any kind of plugin in QtWebkit (Flash, or an SVG Viewer Plugin for ex.) to fetch and drop the right click mouse event? The QWebView should "eat" those events and don't delegate them to the underlying plugin.

  4. #4
    Join Date
    Aug 2009
    Posts
    11
    Thanks
    1

    Default Re: Handling mouse events in Qt WebKit

    Netscape plugins operate in two modes:

    * Windowed mode - The plugin has a native window handle of it's own. This means that the plugin has complete control over mouse, keyboard, paint events. It can do whatever it wants, whenever it wants.
    * Windowless mode - The plugin does not have a native window. Instead it relies on the browser to tell it where to paint and expects the browser to provide it with keyboard/mouse events. See mozilla site for more information.

    Flash has a wmode parameter that triggers the above modes. The default is Windowed mode. When wmode is 'transparent' or 'opaque', flash requests windowless mode. Note that the mode used ultimately resides with the plugin (i.e the browser cannot force a mode).

    Read more http://trac.webkit.org/wiki/QtWebKitPlugins
    If flash plugin is embeded to page in Window Mode, you cann't interact with it.
    If in Windowless Mode, flash plugin is similar a element in web page, you can interact with it. But I think you can't do anything if no help from inside flash coding.

  5. #5
    Join Date
    Dec 2007
    Posts
    27
    Thanks
    1
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Handling mouse events in Qt WebKit

    Thanks hvitual. But windowsless mode did not work. The QWebView will not show the plugin in this mode

    I found another solution to "steal" the mouse events.

    First I find the widget which holds the plugin in an QWebView. Then I register a slot to the signal "clientIsEmbedded()" (Because we have to wait for the plugin to embed).
    Qt Code:
    1. void WebView::page_loaded(bool ok)
    2. {
    3. QList<QX11EmbedContainer*> l
    4. = this->findChildren<QX11EmbedContainer*>();
    5.  
    6. foreach(QX11EmbedContainer* x11cont, l) {
    7. connect(x11cont, SIGNAL(clientIsEmbedded()), this,
    8. SLOT(client_embedded()));
    9. }
    10. } // WebView::page_loaded(...)
    To copy to clipboard, switch view to plain text mode 

    In the slot "client_embedded()" I will use the XLib function "XGrabButton" to steal mouse button 3 (right button). All right click events will now be processed by my qt application. Flash will not show the context menu anymore
    Qt Code:
    1. void WebView::client_embedded()
    2. {
    3. QX11EmbedContainer* x11cont = static_cast<QX11EmbedContainer*>(sender());
    4.  
    5. XGrabButton(QX11Info::display(), 3, AnyModifier,
    6. x11cont->clientWinId(),
    7. false, ButtonPressMask, GrabModeAsync, GrabModeAsync,
    8. 0L, 0L);
    9. }
    To copy to clipboard, switch view to plain text mode 

    The next question is: How to do so under Windows?

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Handling mouse events in Qt WebKit

    Quote Originally Posted by yakin View Post
    The next question is: How to do so under Windows?
    http://msdn.microsoft.com/en-us/libr...89(VS.85).aspx

  7. The following user says thank you to tbscope for this useful post:

    yakin (25th August 2010)

  8. #7
    Join Date
    Apr 2011
    Posts
    1
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Handling mouse events in Qt WebKit

    Quote Originally Posted by yakin View Post
    Thanks hvitual. But windowsless mode did not work. The QWebView will not show the plugin in this mode

    I found another solution to "steal" the mouse events.

    First I find the widget which holds the plugin in an QWebView. Then I register a slot to the signal "clientIsEmbedded()" (Because we have to wait for the plugin to embed).
    Qt Code:
    1. void WebView::page_loaded(bool ok)
    2. {
    3. QList<QX11EmbedContainer*> l
    4. = this->findChildren<QX11EmbedContainer*>();
    5.  
    6. foreach(QX11EmbedContainer* x11cont, l) {
    7. connect(x11cont, SIGNAL(clientIsEmbedded()), this,
    8. SLOT(client_embedded()));
    9. }
    10. } // WebView::page_loaded(...)
    To copy to clipboard, switch view to plain text mode 

    In the slot "client_embedded()" I will use the XLib function "XGrabButton" to steal mouse button 3 (right button). All right click events will now be processed by my qt application. Flash will not show the context menu anymore
    Qt Code:
    1. void WebView::client_embedded()
    2. {
    3. QX11EmbedContainer* x11cont = static_cast<QX11EmbedContainer*>(sender());
    4.  
    5. XGrabButton(QX11Info::display(), 3, AnyModifier,
    6. x11cont->clientWinId(),
    7. false, ButtonPressMask, GrabModeAsync, GrabModeAsync,
    8. 0L, 0L);
    9. }
    To copy to clipboard, switch view to plain text mode 

    The next question is: How to do so under Windows?
    Great job man,this work like a charm

Similar Threads

  1. Handling parent und child events at once.
    By dentist in forum Newbie
    Replies: 3
    Last Post: 2nd April 2010, 10:55
  2. Handling mouse click events in QGraphicsItem
    By Luc4 in forum Qt Programming
    Replies: 7
    Last Post: 5th March 2010, 16:12
  3. mouse events handling with QGraphicsItem
    By trallallero in forum Qt Programming
    Replies: 3
    Last Post: 21st October 2009, 14:15
  4. Handling Mouse Events of a parent widget
    By dvmorris in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2007, 18:44
  5. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 06:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.