Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Sending a mouseclick to a Cocoa window in a Carbon app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending a mouseclick to a Cocoa window in a Carbon app



Interestingly enough, I have in the past found it necessary to provoke a WebView to update. In my case I found mouse-moved events did the trick, but perhaps the gist of what I'm doing will serve as a model for how you might fake a mouse click? I had to surgically extract the source below from my project, but hopefully it's still functional. In my case I know the size of the view, so it's just hardcoded to 100,100, but you can change that.

I assume you can create and send an NSEvent even if you're a Carbon app at heart. If the idea is just to convince the WebView...

// Owning window will be nil if the view is hidden, say, in another tab ...
if (owningWindow != nil)
{
// Fake a position 100, 100 into the web view
NSPoint moveLocation = [_myWebKitView convertPoint:NSMakePoint(100, 100) toView:nil];


NSEvent* fakeMouseMoved = [NSEvent mouseEventWithType:NSMouseMoved location:moveLocation modifierFlags:0 timestamp:[NSDate timeIntervalSinceReferenceDate] windowNumber: [owningWindow windowNumber] context:[NSGraphicsContext graphicsContextWithWindow:owningWindow] eventNumber:0 clickCount:1 pressure:0];

// It seems that one mousemoved event is not always enough to get the contents updated,
// but three seems to do the trick, even if it's the same darned thing sent repeatedly...
[_myWebKitView mouseMoved:fakeMouseMoved];
[_myWebKitView mouseMoved:fakeMouseMoved];
[_myWebKitView mouseMoved:fakeMouseMoved];
}


Hope this helps,
Daniel

On Oct 30, 2005, at 4:59 PM, Chilton Webb wrote:

Hi,

I have a Carbon app with one window with WebKit content created from a Cocoa plug-in. However, the WebKit content in it is not always responsive when the app is brought to the foreground. The window it's in is in the foreground, though.

A click in the center of the window fixes the problem. Until I have more time to explore why this is, what's the easiest way to simulate or pass a click to that window?

Thanks,
-Chilton
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Sending a mouseclick to a Cocoa window in a Carbon app (From: Chilton Webb <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.