Question
I'm new to Tizen development and have created an application with three views using the UI Builder. The application contains managed code that I cannot modify.
In View 2, I have two entry fields displaying information. I need to change the text in these entries when a button in View 3 is clicked. While I can successfully read the text from these entries, I'm unable to set new text values.
I've tried several methods without success. Here's some of the code I attempted:
void vTimeSet_btnTimeBack_onpressed(uib_vTimeSet_view_context *vc, Evas_Object *obj, void *event_info) {
uib_app_manager_st* uib_app_manager = uib_app_manager_get_instance();
uib_vEinstellungen_view_context* vE = (uib_vEinstellungen_view_context*)uib_app_manager->find_view_context("vEinstellungen");
const char *s = elm_entry_entry_get(vE->enSettingsStart); // Reading text works
if (bStart) {
elm_object_text_set(&vE->enSettingsStart, "Juhu"); // Setting text doesn't work
evas_object_show(vE->enSettingsStart);
} else {
elm_object_text_set(vE->enSettingsStop, "Stop");
evas_object_show(vE->enSettingsStop);
}
Elm_Object_Item* navi_item = uib_util_push_view("vEinstellungen");
elm_object_text_set(vE->enSettingsStart, "Juhu");
evas_object_show(vE->enSettingsStart);
evas_object_show(vE->view_name);
s = elm_entry_entry_get(vE->enSettingsStart);
}
The text appears to change when I read it back, but the view continues to display the old value. When the event triggers again, the old value reappears, suggesting the change isn't being persisted in the entry object.
Answer
Problem Understanding
The core issue involves:
- Text changes not persisting in entry fields across view transitions
- Views being recreated each time they're accessed, resetting all values
- Difficulty in modifying entry text from a different view
Solution Methods
-
Correct API Usage:
- Remove the incorrect
&operator when callingelm_object_text_set() - Use
elm_entry_entry_set()instead ofelm_object_text_set()for entry widgets
- Remove the incorrect
-
Persistent Data Storage:
- Store the modified text values in a persistent location (like app data or global variables)
- Update the entry fields each time the view is created
-
View Management:
- Avoid recreating views unnecessarily
- Consider using a single view with dynamic content changes instead of multiple views
Code Examples
// Correct way to set entry text
elm_entry_entry_set(vE->enSettingsStart, "New Text");
// Persistent storage example
static char *persistentText = NULL;
void button_clicked_cb() {
persistentText = strdup("New Persistent Text");
// Navigate to view
}
void view_create_cb() {
if (persistentText) {
elm_entry_entry_set(vE->enSettingsStart, persistentText);
}
}
Additional Tips
- Use the Tizen application data storage APIs for more robust persistence
- Consider using signals or callbacks to communicate between views
- Verify view lifecycle management in your application
- For complex UI interactions, consider using the EFL Elementary API more extensively