Add screen_widget_broadcast()
This commit is contained in:
@ -27,6 +27,10 @@ struct widget_t *screen_widget_add_from_file(struct screen_t *s, char *fn);
|
||||
bool screen_widget_destroy(struct screen_t *s, struct widget_t **w);
|
||||
|
||||
uint16_t screen_get_num_widgets(struct screen_t *s);
|
||||
|
||||
struct widget_t *screen_widget_find_by_xy(struct screen_t *s, uint16_t x, uint16_t y);
|
||||
|
||||
void screen_widget_broadcast(struct screen_t *s, int ev, void *ev_data);
|
||||
|
||||
|
||||
#endif //__SCREEN_H
|
||||
|
13
src/screen.c
13
src/screen.c
@ -155,6 +155,19 @@ struct widget_t *screen_widget_find_by_xy(struct screen_t *s, uint16_t x, uint16
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void screen_widget_broadcast(struct screen_t *s, int ev, void *ev_data) {
|
||||
struct widget_list_t *wl;
|
||||
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
SLIST_FOREACH(wl, &s->widget_entries, entries) {
|
||||
if (wl->widget->handler)
|
||||
wl->widget->handler(ev, wl->widget, ev_data);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void screen_widget_set_handler(struct screen_t *s, widget_event_fn handler) {
|
||||
if (!s)
|
||||
return;
|
||||
|
Reference in New Issue
Block a user