@implementation wxNSButton
-- (id)initWithFrame:(NSRect)frame
++ (void)initialize
{
- [super initWithFrame:frame];
- impl = NULL;
- [self setTarget: self];
- [self setAction: @selector(clickedAction:)];
- return self;
-}
-
-- (void) clickedAction: (id) sender
-{
- if ( impl )
+ static BOOL initialized = NO;
+ if (!initialized)
{
- wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
- if ( wxpeer )
- wxpeer->HandleClicked(0);
+ initialized = YES;
+ wxOSXCocoaClassAddWXMethods( self );
}
}
-- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation
-{
- impl = theImplementation;
-}
-
-- (wxWidgetCocoaImpl*) implementation
-{
- return impl;
-}
-
-- (BOOL) isFlipped
-{
- return YES;
-}
-
- (int) intValue
{
switch ( [self state] )
[v setButtonType:NSMomentaryPushInButton];
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
- [v setImplementation:c];
return c;
/*
OSStatus err;
void wxWidgetCocoaImpl::SetDefaultButton( bool isDefault )
{
- if ( [m_osxView isKindOfClass:[NSButton class]] )
- [(NSButton*)m_osxView setKeyEquivalent: isDefault ? @"\r" : nil ];
+ if ( isDefault && [m_osxView isKindOfClass:[NSButton class]] )
+ // NOTE: setKeyEquivalent: nil will trigger an assert
+ // instead do not call in that case.
+ [(NSButton*)m_osxView setKeyEquivalent: @"\r" ];
}
void wxWidgetCocoaImpl::PerformClick()
[v setTitle:wxCFStringRef( label).AsNSString()];
[v setImagePosition:NSImageRight];
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
- [v setImplementation:c];
return c;
}