I might have compiled the library in Xcode 2.5 under 10.4. I had to make some modifications to juce_mac_NSViewComponentPeer.mm to eliminate property access on NSEvent* e(e.modifierFlags & …)
Specifically
[code]static void updateModifiers (NSEvent* e)
{
int m = currentModifiers & ~(ModifierKeys::shiftModifier | ModifierKeys::ctrlModifier
| ModifierKeys::altModifier | ModifierKeys::commandModifier);
if (([e modifierFlags] & NSShiftKeyMask) != 0)
m |= ModifierKeys::shiftModifier;
if (([e modifierFlags] & NSControlKeyMask) != 0)
m |= ModifierKeys::ctrlModifier;
if (([e modifierFlags] & NSAlternateKeyMask) != 0)
m |= ModifierKeys::altModifier;
if (([e modifierFlags] & NSCommandKeyMask) != 0)
m |= ModifierKeys::commandModifier;
currentModifiers = m;
}[/code]
&
[code]
-
(void) keyDown: (NSEvent*) ev
{
bool used = false;if (owner != 0)
{
updateKeysDown (ev, true);
used = owner->handleKeyEvent (ev, true);if (([ev modifierFlags] & NSCommandKeyMask) != 0) { // for command keys, the key-up event is thrown away, so simulate one.. updateKeysDown (ev, false); used = owner->handleKeyEvent (ev, false) || used; }
}
if (! used)
[super keyDown: ev];
}[/code]
Also for some reason the AvailabilityMacros for 10.4 wasn’t being picked up so I got frustrated and just
#define MACOS_10_4_OR_EARLIER 1
before
#include “…/…/…/src/juce_core/basics/juce_StandardHeader.h”
in
juce_mac_NativeIncludes.h
I haven’t actually linked it in yet…
And a suggestion for Julian below…
/******************************************/
[quote] Using POSIX Threads in Cocoa
NSThreads are built upon POSIX threads (pthreads). You can create your
own pthreads, but you must be cautious about using Cocoa from them.
When you detach an NSThread, Cocoa enters a multithreaded mode, which
activates greater thread safety measures. When you create your own
pthreads, Cocoa does not know to change modes. To force Cocoa into its
multithreaded mode, you must detach an NSThread, which could
immediately exit. To identify whether Cocoa is already in
multithreaded mode, use the NSThread class method isMultiThreaded.[/quote]
I think 10.5 handles all this automatically. But in 10.4 I make sure my app is multithreaded(as I use a variety of NSThread and pthreads)
Here is my code I call when my app init’s
@interface MTCocoaSafe : NSObject
{
}
+ (id)initializeCocoaThreads;
@end
@implementation MTCocoaSafe
+ (id)initializeCocoaThreads
{
id instance=[[self alloc]init];
if (!instance)
return nil;
if (![NSThread isMultiThreaded])
[NSThread detachNewThreadSelector:@selector(goMultiThreaded) toTarget:instance withObject:nil];
return [instance autorelease];
}
- (void)goMultiThreaded
{
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init];
[pool release];
}
@end
[MTCocoaSafe initializeCocoaThreads];
[/b]