]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/NSButton.mm
mouse event handling extended
[wxWidgets.git] / src / cocoa / NSButton.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/NSButton.cpp
3 // Purpose: wxCocoaNSButton
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/01/31
7 // RCS-ID: $Id:
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/wxprec.h"
21 #ifndef WX_PRECOMP
22 #include "wx/log.h"
23 #endif // WX_PRECOMP
24
25 #include "wx/cocoa/ObjcPose.h"
26
27 #include "wx/cocoa/NSButton.h"
28 #import <AppKit/NSButton.h>
29
30 // ----------------------------------------------------------------------------
31 // globals
32 // ----------------------------------------------------------------------------
33 WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSButton)
34
35 // ============================================================================
36 // @class wxPoserNSButton
37 // ============================================================================
38 @interface wxPoserNSButton : NSButton
39 {
40 }
41
42 - (void)wxNSButtonAction: (id)sender;
43 @end // wxPoserNSButton
44
45 WX_IMPLEMENT_POSER(wxPoserNSButton);
46
47 @implementation wxPoserNSButton : NSButton
48 - (void)wxNSButtonAction: (id)sender
49 {
50 wxASSERT_MSG((id)self==sender,"Received wxNSButtonAction from another object");
51 wxCocoaNSButton *button = wxCocoaNSButton::GetFromCocoa(self);
52 wxCHECK_RET(button,"wxNSButtonAction received without associated wx object");
53 button->Cocoa_wxNSButtonAction();
54 }
55
56 @end // implementation wxPoserNSButton
57
58 void wxCocoaNSButton::AssociateNSButton(WX_NSButton cocoaNSButton)
59 {
60 if(cocoaNSButton)
61 {
62 sm_cocoaHash.insert(wxCocoaNSButtonHash::value_type(cocoaNSButton,this));
63 [cocoaNSButton setTarget: cocoaNSButton];
64 [cocoaNSButton setAction: @selector(wxNSButtonAction:)];
65 }
66 }
67