ui/winui/commandbar.cpp

branch
newapi
changeset 382
de653b07050b
parent 226
4eef1d49f794
equal deleted inserted replaced
381:b47bda6666ce 382:de653b07050b
134 } 134 }
135 if(item->args.icon) { 135 if(item->args.icon) {
136 button.Icon(ui_get_icon(item->args.icon)); 136 button.Icon(ui_get_icon(item->args.icon));
137 } 137 }
138 138
139 UIElement elm = button;
140 UiWidget* widget = new UiWidget(elm);
141 ui_context_add_widget_destructor(obj->ctx, widget);
142 ui_set_widget_groups(obj->ctx, widget, item->args.groups);
143
139 // register callback 144 // register callback
140 if (item->args.onclick) { 145 if (item->args.onclick) {
141 ui_callback cbfunc = item->args.onclick; 146 ui_callback cbfunc = item->args.onclick;
142 void* cbdata = item->args.onclickdata; 147 void* cbdata = item->args.onclickdata;
143 button.Click([cbfunc, cbdata, obj](Windows::Foundation::IInspectable const& sender, RoutedEventArgs) { 148 button.Click([cbfunc, cbdata, obj](Windows::Foundation::IInspectable const& sender, RoutedEventArgs) {
168 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, nullptr, item->args.varname, UI_VAR_INTEGER); 173 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, nullptr, item->args.varname, UI_VAR_INTEGER);
169 if (var) { 174 if (var) {
170 UIElement elm = button; 175 UIElement elm = button;
171 UiWidget* widget = new UiWidget(elm); 176 UiWidget* widget = new UiWidget(elm);
172 ui_context_add_widget_destructor(obj->ctx, widget); 177 ui_context_add_widget_destructor(obj->ctx, widget);
178 ui_set_widget_groups(obj->ctx, widget, item->args.groups);
173 179
174 UiInteger* value = (UiInteger*)var->value; 180 UiInteger* value = (UiInteger*)var->value;
175 int64_t i = value->value; 181 int64_t i = value->value;
176 value->get = ui_toggle_button_get; 182 value->get = ui_toggle_button_get;
177 value->set = ui_toggle_button_set; 183 value->set = ui_toggle_button_set;

mercurial