Sending mouseclicks to WebView-Objects

Discussion in 'Programmer Misc' started by Alexander Clauss, Sep 17, 2007.

  1. I'd like to use clicks with the third/middle mouse button in a WebView
    to open the clicked links as new Tab. But how can this be done?


    I've already tried the following:

    1) subclassing WebView and overwriting "otherMouseDown:" and in this
    method creating a new NSEvent-Object with for NSLeftMouseDown event
    and special modifier Flags and passing this to the mouseDown: method.

    This didn't work, because WebView doesn't use mouseDown at all, so
    calling "mouseDown:" on a WebView does nothing.

    I tried to call "[NSApp postEvent:event atStart:YES|NO]", "[NSApp
    sendEvent:event]" and "[NSWindow sendEvent:event]" instead from
    "otherMouseDown:", but this didn't work either.


    2) I checked for the otherMouseDown/otherMouseUp event from within the
    delegate method "webView:mouseDidMoveOverElement:modifierFlags:", but
    while this method gets called for mouseMove events and leftMouseUp
    events, it will never called for "otherMouse" events.


    So how can I pass mouseEvents to WebView, or alternativly, how can
    WebView be forced to react on a click with the third/middle mouse
    button?
     
    Alexander Clauss, Sep 17, 2007
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.