2017-09-23 48 views
0

我的EDC佈局文件中有一個文本字段,我想在點擊按鈕時獲取這些數據。我對此毫不知情。那麼,有人會幫助我嗎?如何獲取Tizen中EDC文件中的textfield數據?

+0

你能提供的EDC佈局的相關部分,並在那裏你想要得到的文本數據(EDC中或使用佈局應用程序中的腳本)。 – LeBlue

回答

0

該代碼是從佈局和按鈕examples。這裏還有其他語言綁定的例子(c,C++,js)。

對應按鈕和佈局的Tizen documentation(原生)。

.edc佈局文件的文本部分"title"和佔位符/ SWALLOW部分"placerholder"放入一個按鈕。

collections { 
    group { 
     name: "example/mylayout"; 
     data { 
     item: "title" "Layout Example 01"; 
     } 

     parts { 
     part { 
      name: "example/title"; 
      type: TEXT; 

      description { 
       state: "default" 0.0; 
       color: 0 0 0 255; 
       rel1 { 
        relative: 0.0 0.0; 
        offset: 0 0; 
       } 
       rel2 { 
        relative: 1.0 0.5; 
        offset: -1 -1; 
       } 
       text { 
        text: "bla"; 
        size: 16; 
        font: "sans"; 
        min: 1 1; 
        ellipsis: -1; 
       } 
      } 
     } 
     part { 
      name: "placleholder"; 
      type: SWALLOW; 

      description { 
       state: "default" 0.0; 
       fixed: 1 1; 

       rel1 { 
        relative: 0.0 0.5; 
        offset: 0 0; 
       } 
       rel2 { 
        relative: 1.0 1.0; 
        offset: -1 -1; 
       } 
      } 
     } 
    } 
} 

要設置佈局,添加一個按鈕,並閱讀好舊的C的"title"部分的文字看起來是這樣的(不是一個完整的工作示例,因爲我不能測試):

要設置佈局:

Evas_Object *win, *bt, *layout; 

    // Create a window (I don't know if this works in tizen like this.) 
    win = elm_win_util_standard_add("layout", "Layout"); 
    elm_win_autodel_set(win, EINA_TRUE); 

    // Adding layout and make it fill the window 
    layout = elm_layout_add(win); 
    evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 
    elm_win_resize_object_add(win, layout); 

    elm_layout_file_set(layout, "/path/to/layoutfile.edj", "example/mylayout"); 
    evas_object_show(layout); 

要添加一個按鈕:

bt = elm_button_add(layout); 
    elm_object_text_set(bt, "Get the text"); 

    // put the button into the layout 
    elm_object_part_content_set(layout, "placeholder", bt); 

    // add clicked callback to button, pass the layout reference as data pointer 
    evas_object_smart_callback_add(bt, "clicked", _btn_cb, layout); 

按鈕回調:

static void 
_btn_cb(void *data, Evas_Object *btn EINA_UNUSED, void *event_info EINA_UNUSED) 
{ 
    // data pointer is the layout reference 
    Evas_Object *layout = data; 

    // with the layout reference we can get the text of part "title" 
    const char *text = elm_object_part_text_get(layout, "title"); 
} 

該代碼是從佈局和按鈕examples。這裏還有其他語言綁定的例子(c,C++,js)。

相應Tizen documentation

相關問題