How to use btn in v6.0?

I have port littlevgl v6.0 in N32905,and display normal,and can touch.But I do not know how to use btn event in v6.0. Where we can find the detail ?

QQ%E6%88%AA%E5%9B%BE20190615092725

You need to register an event callback function with lv_obj_set_event_cb(btn1, my_event_cb) and create the event callback like this:


static void my_event_cb(lv_obj_t * obj, lv_event_t event)
{
    switch(event) {
        case LV_EVENT_PRESSED:
            printf("Pressed\n");
            break;

        case LV_EVENT_SHORT_CLICKED:
            printf("Short clicked\n");
            break;

        case LV_EVENT_CLICKED:
            printf("Clicked\n");
            break;

        case LV_EVENT_LONG_PRESSED:
            printf("Long press\n");
            break;

        case LV_EVENT_LONG_PRESSED_REPEAT:
            printf("Long press repeat\n");
            break;

        case LV_EVENT_RELEASED:
            printf("Released\n");
            break;

       /*Etc.*/
}