| 37 |
37 |
| 38 void ui_toolbar_init(void) { |
38 void ui_toolbar_init(void) { |
| 39 |
39 |
| 40 } |
40 } |
| 41 |
41 |
| 42 |
42 static void toolitem_set_enabled(void *item, int enabled) { |
| |
43 NSToolbarItem *i = (__bridge NSToolbarItem*)item; |
| |
44 i.enabled = enabled; |
| |
45 } |
| |
46 |
| |
47 static void toolitem_bind_action(UiContext *ctx, NSToolbarItem *item, const char *action) { |
| |
48 if(action) { |
| |
49 void *widget = (__bridge void*)item; |
| |
50 uic_bind_action(ctx, action, widget, (ui_enablefunc)toolitem_set_enabled); |
| |
51 UiAction *ui_action = uic_resolve_action(ctx, action); |
| |
52 if(!ui_action) { |
| |
53 toolitem_set_enabled(widget, FALSE); |
| |
54 } |
| |
55 } |
| |
56 } |
| 43 |
57 |
| 44 /* --------------------- UiToolbar --------------------- */ |
58 /* --------------------- UiToolbar --------------------- */ |
| 45 |
59 |
| 46 @implementation UiToolbar |
60 @implementation UiToolbar |
| 47 |
61 |
| 217 } |
231 } |
| 218 if(item->args.icon) { |
232 if(item->args.icon) { |
| 219 button.image = ui_cocoa_named_icon(item->args.icon); |
233 button.image = ui_cocoa_named_icon(item->args.icon); |
| 220 } |
234 } |
| 221 |
235 |
| 222 if(item->args.onclick) { |
236 if(item->args.onclick || item->args.action) { |
| 223 EventData *event = [[EventData alloc] init:item->args.onclick userdata:item->args.onclickdata action:item->args.action]; |
237 EventData *event = [[EventData alloc] init:item->args.onclick userdata:item->args.onclickdata action:item->args.action]; |
| 224 event.obj = obj; |
238 event.obj = obj; |
| 225 button.target = event; |
239 button.target = event; |
| 226 button.action = @selector(handleEvent:); |
240 button.action = @selector(handleEvent:); |
| 227 objc_setAssociatedObject(button, "eventdata", event, OBJC_ASSOCIATION_RETAIN); |
241 objc_setAssociatedObject(button, "eventdata", event, OBJC_ASSOCIATION_RETAIN); |
| |
242 |
| |
243 toolitem_bind_action(obj->ctx, button, item->args.action); |
| 228 } |
244 } |
| 229 return button; |
245 return button; |
| 230 } |
246 } |
| 231 |
247 |
| 232 NSToolbarItem* ui_nstoolbaritem_create_toggle(UiObject *obj, UiToolbarToggleItem *item, NSString *identifier) { |
248 NSToolbarItem* ui_nstoolbaritem_create_toggle(UiObject *obj, UiToolbarToggleItem *item, NSString *identifier) { |