Cocoa NSApp and Tcl/Tk Carbon conflicts

View: New views
3 Messages — Rating Filter:   Alert me  

Cocoa NSApp and Tcl/Tk Carbon conflicts

by Youness Alaoui-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
As I've explained in the previous thread about Embeding an NSView in Tk, I'm using gstreamer to do some video conferencing which provides us with an NSView.. So what I ended up doing was to create an NSWindow and put the NSView in it.. this is causing me some problems with Tk.. here are the issues I have :
I have to handle the Cocoa runloop myself so I set a timer and handle the events with [NSApp nextEventMatchingMask:untilDate:inMode:dequeue: ] method, then use [NSApp sendEvent:] to send the event to my window so they can process them.. the problem is that it looks like the events are shared between the Cocoa and Carbon runloops, so when my function gets an event, Tk misses it, and when Tk gets an event, my code misses it.. this causes some kind of race between my code and Tk, which causes a random race between my windows in which either the Cocoa window or the Tk windows are not getting notified of my mouse pressed, so I sometimes can't focus on a window, etc...
Do you have any idea on how to solve this ?
The second issue I have is that as soon as I create the NSApp, when clicking on the dock icon for aMSN, aMSN doesn't get notified anymore that the dock was clicked, so I'm unable to restore my main window... Do you have any idea on how to reset that so that Carbon/Tk gets notified that the dock has been clicked ?
Finally, there are some other smaller issues, like the fact that I keep having two window borders with 'focus' in it, the Tk Carbon focused window and the previously focused Cocoa window (or the other way around), as well as my NSWindows not appearing in the list of Windows in the menubar, and I can't Ctrl-` to cycle through them...
Anyone has enough Cocoa/Tk knowledge to help me with that ?
p.s.: yes I know about the Tk 8.5 Cocoa backport, but I don't want to use that since I want to keep 10.3.9 compatibility support for aMSN
Thanks,
KaKaRoTo


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Cocoa NSApp and Tcl/Tk Carbon conflicts

by Kevin Walzer-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> p.s.: yes I know about the Tk 8.5 Cocoa backport, but I don't want to
> use that since I want to keep 10.3.9 compatibility support for aMSN


KaKaRoTo,

Did you look at this document?

http://developer.apple.com/documentation/Cocoa/Conceptual/CarbonCocoaDoc/CarbonCocoaDoc.html#//apple_ref/doc/uid/10000193

It discussed ways to integrate Cocoa GUI elements in a Carbon app, and
is not limited to HICocoaView. Some of these strategies might work for
you if you want to preserve 10.3.9 compat.

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Parent Message unknown Re: Cocoa NSApp and Tcl/Tk Carbon conflicts

by Kevin Walzer-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

(copying to the list for posterity)

Hey KaKaRoTo,

Glad you found that reference helpful. I also had to use
NSApplicationLoad() in a couple of my Tk extensions that call into Cocoa
methods, and it works great...my Cocoa-based Tk extensions work equally
well with Cocoa and Carbon Tk.

Best,
Kevin

On 8/9/09 4:58 AM, Youness Alaoui wrote:

> Hey Kevin!
> Thanks for answering me!
> No, I didn't find any document like that, I've just read it quickly and
> it's EXACTLY what I needed, thanks a lot for your help! I've now changed
> my code to use NSApplicationLoad() instead of [NSApplication
> sharedApplication] and removed all the cocoa event loop timer and it
> works flawlessly now! Even clicking on the dock makes it open my main
> window now, as expected!
> I still can't cycle through my windows, but I really don't care about
> that.. there are no more lost events, code is simpler, and the windows
> work fine! :) So thanks a lot for showing me that document! :)
> Thanks,
> KaKaRoTo!
>
> On Sun, Aug 9, 2009 at 12:27 AM, Kevin Walzer <kw@...
> <mailto:kw@...>> wrote:
>
>
>         p.s.: yes I know about the Tk 8.5 Cocoa backport, but I don't
>         want to
>         use that since I want to keep 10.3.9 compatibility support for aMSN
>
>
>
>     KaKaRoTo,
>
>     Did you look at this document?
>
>     http://developer.apple.com/documentation/Cocoa/Conceptual/CarbonCocoaDoc/CarbonCocoaDoc.html#//apple_ref/doc/uid/10000193
>
>     It discussed ways to integrate Cocoa GUI elements in a Carbon app,
>     and is not limited to HICocoaView. Some of these strategies might
>     work for you if you want to preserve 10.3.9 compat.
>
>     --Kevin
>
>     --
>     Kevin Walzer
>     Code by Kevin
>     http://www.codebykevin.com
>
>


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac