ui/cocoa/button.m

changeset 113
dde28a806552
parent 112
c3f2f16fa4b8
equal deleted inserted replaced
112:c3f2f16fa4b8 113:dde28a806552
27 */ 27 */
28 28
29 #import "button.h" 29 #import "button.h"
30 #import "EventData.h" 30 #import "EventData.h"
31 #import "Container.h" 31 #import "Container.h"
32 #import "image.h"
32 #import <objc/runtime.h> 33 #import <objc/runtime.h>
33 34
34 #import <cx/buffer.h> 35 #import <cx/buffer.h>
35 #import <cx/json.h> 36 #import <cx/json.h>
36 37
39 button.translatesAutoresizingMaskIntoConstraints = NO; 40 button.translatesAutoresizingMaskIntoConstraints = NO;
40 if(args->label) { 41 if(args->label) {
41 NSString *label = [[NSString alloc] initWithUTF8String:args->label]; 42 NSString *label = [[NSString alloc] initWithUTF8String:args->label];
42 button.title = label; 43 button.title = label;
43 } 44 }
45 if(args->icon) {
46 button.image = ui_cocoa_named_icon(args->icon);;
47 }
44 48
45 if(args->onclick) { 49 if(args->onclick) {
46 EventData *event = [[EventData alloc] init:args->onclick userdata:args->onclickdata]; 50 EventData *event = [[EventData alloc] init:args->onclick userdata:args->onclickdata];
47 event.obj = obj; 51 event.obj = obj;
48 button.target = event; 52 button.target = event;
69 //[button setAllowsMixedState:YES]; 73 //[button setAllowsMixedState:YES];
70 74
71 if(args->label) { 75 if(args->label) {
72 NSString *label = [[NSString alloc] initWithUTF8String:args->label]; 76 NSString *label = [[NSString alloc] initWithUTF8String:args->label];
73 button.title = label; 77 button.title = label;
78 }
79 if(args->icon) {
80 button.image = ui_cocoa_named_icon(args->icon);
74 } 81 }
75 82
76 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_INTEGER); 83 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_INTEGER);
77 if(var) { 84 if(var) {
78 UiInteger *i = var->value; 85 UiInteger *i = var->value;

mercurial