Just wanted to follow up on this so the list archive has a solution in case anyone searches for anything similar in the future. The solution is courtesy of Darin Adler over on webkitsdk-dev.

The solution is to override -[NSWindow sendEvent:] and if the window is not main send the NSLeftMouseDown event twice. The first time the window will become main (and possibly key) and the second will start the drag:

-(void)sendEvent:(NSEvent*)event
{
        if (NSLeftMouseDown == [event type]
                        && ![self isMainWindow])
&& [_webView mouse:[_webView convertPoint:[event locationInWindow] fromView:nil] inRect:[_webView visibleRect]]) {
                [super sendEvent:event];
        }

        [super sendEvent:event];
}

The side effect of this is that the NSPanel is now at least the main window, which brings me to my next question.

This application is an 'agent' where LSUIElement is set to YES in Info.plist. However, I don't want the agent application to come to the front as this stops events being directed at the last current application. In practice this is OK for some events (mouse down for example) as they change the current application. However, it is confusing in that if you, for example, use cmd+Q then the NSPanel application is quit rather than the one that was in the front.

How do I make the agent application I am working on forward on events to the last current application?
Nick

On Sep 23, 2008, at 3:36 pm, Nick Beadman wrote:

Ben,

On Sep 23, 2008, at 8:19 am, Benjamin Stiglitz wrote:

The problem I am having is that to drag out of the WebView the panel has to be main (i.e. the close/minimize/zoom buttons are filled in). However, if you hold down the command key, the drag out of that window works fine.

Where do I start looking to make this work without having to hold down the command key?

Have you looked at -[NSView acceptsFirstMouse:]?

Thanks for the heads up. This does look like what I need, however, it requires me to override the NSView's that make up WebView. Simply sub-classing WebView and returning YES from acceptsFirstMouse: doesn't work.

Looking back through the stack trace from the WebUIDelegate methods it appears that the actual class I am trying to change the implementation of acceptsFirstMouse: is the private WebHTMLView.

It is not clear to me where to go from here. poseAs: is deprecated and even then I am dealing with a private class. I am going to try and see if I can get either -[NSApplication sendEvent:] or - [NSWindow sendEvent:] to temporarily bring the window to the front before sending on the event.

Any other ideas are welcomed,
Nick

--
Nick Beadman
[EMAIL PROTECTED]
(sent from my mailing list account, [EMAIL PROTECTED])

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to