Here is my problem, i have a nib-less app, this app displays (with a fade-in/fade-out effect) a NSWindow which looks like a 10.8 notification.
On this notification i have 2 NSButtons which are created programmatically like that :
NSImage *btnNeutral = [[NSImage imageNamed:@"btn-toaster-n.png"] retain];
[btnNeutral setTemplate:NO];
NSImage *btnPressed = [[NSImage imageNamed:@"btn-toaster-clic.png"] retain];
[btnPressed setTemplate:NO];
m_connectButton = [[NSButton alloc] initWithFrame:NSMakeRect(284, 49, 77, 22)];
[m_connectButton setTarget:self];
[m_connectButton setAction:@selector(connect:)];
[m_connectButton setImage:btnNeutral];
[m_connectButton setAlternateImage:btnPressed];
[m_connectButton setButtonType:NSMomentaryChangeButton];
[[m_connectButton cell] setImageDimsWhenDisabled:NO];
[m_connectButton setBordered:NO];
[m_connectButton setFocusRingType:NSFocusRingTypeExterior];
[m_connectButton setTitle:Localizer::getInstance()->getLocalizedString(@"SYSTRAY_BALLOON_CONNECT_ACTION")];
[m_connectButton setEnabled:YES];
[self addSubview:m_connectButton];
Note : my NSWindow is transparent, my NSView is transparent but skinned with a NSImage as are my buttons.
Problem : when i click on one of the 2 buttons, it works 1 out of 5 times...
Where does the problem come from ? Thread issue ? Transparency ?
Thanks for your input !
@Rob Keniger : yes i have a runloop, i init my app with this :
[NSApplication sharedApplication];
I also have a dynamic NSMenuBar is that app which works fine.
EDIT I found a workaround but i'd like to know what i'm missing here. I just put the initialization of the buttons from the initWithFrame method of my custom view to the initWithContentRect method of my window hosting this same view. Any idea why it works that way ?