Search code examples
tizentizen-native-app

How to add edit text in native Tizen app?


I try to understand the GUI creation in native Tizen app. Now I can add label and button. But I cannot find any solution how to add text edit (android TextEdit).

The button I add by below code:

   ad->button = elm_button_add(ad->box1);
   evas_object_smart_callback_add(ad->button, "clicked", btn_clicked_cb, ad);
   evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, 0.1);
   evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
   elm_object_text_set(ad->button, "Preform");
   evas_object_show(ad->button);
   elm_box_pack_end(ad->box1, ad->button);

so I try to search elm_edit_text_add function but with no result.


Solution

  • This is the code for a single line Entry (TextEdit equivalent):

        Evas_Object *entry;
        Evas_Object *layout;
        Evas_Object *scroller;
        Evas_Object *box;
        Evas_Object *nf = data;
    
        scroller = elm_scroller_add(nf);
    
        box = elm_box_add(scroller);
        evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
        evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
        elm_object_content_set(scroller, box);
    
        layout = elm_layout_add(box);
        elm_layout_file_set(layout, ELM_DEMO_EDJ, "entry_layout");
        evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0);
        evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0);
    
        entry = elm_entry_add(layout);
        elm_entry_single_line_set(entry, EINA_TRUE);
        elm_entry_scrollable_set(entry, EINA_TRUE);
        eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
        evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
        evas_object_smart_callback_add(entry, "activated", entry_activated_cb, NULL);
        elm_object_part_content_set(layout, "entry_part", entry);
    
        elm_box_pack_end(box, layout);
        evas_object_show(layout);
    

    For more types of entries look at the examples provided with the tizen SDK.