mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Add msgbox
This commit is contained in:
parent
a877e2750a
commit
b2093b5947
@ -1298,6 +1298,9 @@ static void hasp_process_obj_attribute_txt(lv_obj_t* obj, const char* attr, cons
|
||||
lv_roller_get_selected_str(obj, buffer, sizeof(buffer));
|
||||
return attr_out_str(obj, attr, buffer);
|
||||
}
|
||||
if(check_obj_type(obj, LV_HASP_MSGBOX)) {
|
||||
return update ? lv_msgbox_set_text(obj, payload) : attr_out_str(obj, attr, lv_msgbox_get_text(obj));
|
||||
}
|
||||
#if LV_USE_WIN != 0
|
||||
if(check_obj_type(obj, LV_HASP_WINDOW)) {
|
||||
// return update ? lv_win_set_title(obj, (const char *)payload) : attr_out_str(obj, attr,
|
||||
|
@ -489,6 +489,39 @@ void btnmatrix_event_handler(lv_obj_t* obj, lv_event_t event)
|
||||
// if(max > 0) dispatch_normalized_group_value(obj->user_data.groupid, obj, val, 0, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a msgbox value has changed
|
||||
* @param obj pointer to a dropdown list or roller
|
||||
* @param event type of event that occured
|
||||
*/
|
||||
void msgbox_event_handler(lv_obj_t* obj, lv_event_t event)
|
||||
{
|
||||
log_event("msgbox", event);
|
||||
|
||||
uint8_t hasp_event_id;
|
||||
if(!translate_event(obj, event, hasp_event_id)) return; // Use LV_EVENT_VALUE_CHANGED
|
||||
|
||||
/* Get the new value */
|
||||
char buffer[128];
|
||||
uint16_t val = 0;
|
||||
|
||||
val = lv_msgbox_get_active_btn(obj);
|
||||
if(val != LV_BTNMATRIX_BTN_NONE) {
|
||||
const char* txt = lv_msgbox_get_active_btn_text(obj);
|
||||
strncpy(buffer, txt, sizeof(buffer));
|
||||
} else {
|
||||
buffer[0] = 0; // empty string
|
||||
}
|
||||
|
||||
if(hasp_event_id == HASP_EVENT_CHANGED && last_value_sent == val) return; // same value as before
|
||||
|
||||
last_value_sent = val;
|
||||
event_object_selection_changed(obj, hasp_event_id, val, buffer);
|
||||
// if(max > 0) dispatch_normalized_group_value(obj->user_data.groupid, obj, val, 0, max);
|
||||
|
||||
if(hasp_event_id == HASP_EVENT_UP || hasp_event_id == HASP_EVENT_RELEASE) lv_msgbox_start_auto_close(obj, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a slider or adjustable arc is clicked
|
||||
* @param obj pointer to a slider
|
||||
|
@ -17,6 +17,7 @@ void toggle_event_handler(lv_obj_t* obj, lv_event_t event);
|
||||
void slider_event_handler(lv_obj_t* obj, lv_event_t event);
|
||||
void selector_event_handler(lv_obj_t* obj, lv_event_t event);
|
||||
void btnmatrix_event_handler(lv_obj_t* obj, lv_event_t event);
|
||||
void msgbox_event_handler(lv_obj_t* obj, lv_event_t event);
|
||||
void cpicker_event_handler(lv_obj_t* obj, lv_event_t event);
|
||||
|
||||
#if HASP_USE_GPIO > 0
|
||||
|
@ -697,6 +697,17 @@ void hasp_new_object(const JsonObject& config, uint8_t& saved_page_id)
|
||||
}
|
||||
break;
|
||||
|
||||
case LV_HASP_MSGBOX:
|
||||
case HASP_OBJ_MSGBOX:
|
||||
obj = lv_msgbox_create(parent_obj, NULL);
|
||||
if(obj) {
|
||||
lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_event_cb(obj, msgbox_event_handler);
|
||||
if(btnmatrix_default_map) lv_msgbox_add_btns(obj, btnmatrix_default_map);
|
||||
obj->user_data.objid = LV_HASP_MSGBOX;
|
||||
}
|
||||
break;
|
||||
|
||||
case LV_HASP_CALENDER:
|
||||
case HASP_OBJ_CALENDAR:
|
||||
obj = lv_calendar_create(parent_obj, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user