Navigation C API Pages Python bindings Applications

Checkbox widget

A checkbox widget

Checkbox widget

Checkbox attributes can be accessed as widget->checkbox.

Checkbox widget constructor
gp_widget *gp_widget_checkbox_new(const char *label, int val);

gp_widget *gp_widget_checkbox_new2(const char *label, int val,
                                   int (*on_event)(gp_widget_event *ev),
                                   void *priv)

Creates a checkbox widget, label can be NULL.

Function to access and change checkbox value
void gp_widget_checkbox_set(gp_widget *self, int val);

void gp_widget_checkbox_toggle(gp_widget *self);

int gp_widget_checkbox_get(gp_widget *self);

There is a difference between calling the gp_widget_checkbox_get() function and getting the value directly as widget->checkbox->val. The function call is type-safe, which means that the function will return -1 if the widget type is not checkbox, while the direct access will possibly cause undefined behavior if the widget type is not correct.

Table 1. Checkbox JSON attributes
Attribute Type Default Description



Checkbox label




Initial value

Table 2. Checkbox widget events
Widget event value Description


Emitted on checkbox value change.