语言

Menu
Sites
Language
Key board button events

Hi All,

I have created an App which has Entry and Button(Continue) widgets.

On press of Button(Continue) I am showing the next view.

I want to trigger button click event when user press "Enter Key" from keyboard after puting text in entry widget.

How can I listen key board "Enter Button" event?

Thank you.

响应

10 回复
Alex Dem

Hi,
If you want catch 'enter' key onto qwerty keyboard for entry you could use:
    evas_object_smart_callback_add(entry, "activated", entry_changed_cb, NULL);
and perform all necessary actions inside your callback 'entry_changed_cb'.
Or you mean something else?
Alexey.

Dharmesh Guna

Thanks Alex.

Yes exactly. I want to catch enter key.

Will I get the entered/removed character in entry_changed_cb?

What will be the value of enter key? is it '\n' ?

Alex Dem

afaik pressed key does not come into callback method separately. But Evas_Object *obj is pointer to the whole entry.
To get whole text you could use elm_entry_entry_get(obj)
modify it and set with elm_entry_entry_set(Evas_Object *obj, const char *entry);

also fyi, there are some differences between single-line/multiline entry fields.
1) for single-line entry:
- evas_object_smart_callback_add(entry, "changed", entry_changed_cb, NULL);
CB could be added to track every symbol , but for 'enter' key CB is not called.
- evas_object_smart_callback_add(entry, "activated", entry_activated_cb, NULL);
CB could be added to track 'enter' pressure.

2) For multiline entry:
 - registered callback evas_object_smart_callback_add(entry, "activated", entry_activated_cb, NULL); is called for 'enter' key. <br/> tag is added in the end of the current string.
  - evas_object_smart_callback_add(entry, "changed", entry_changed_cb, NULL);
is called if  'enter' key was pressed.
Alexey.

Alex Dem

Just fyi, regarding entry widget and possible callbacks:
https://developer.tizen.org/dev-guide/2.3.0/org.tizen.guides/html/native/ui/ui_widgets_n.htm#entry
Alexey.

연호 조

Hi.

You can use api for keyboard event.

evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_DOWN, func, data;

win : window or some evas object

EVAS_CALLBACK_KEY_DOWN : keyboard pressed.

EVAS_CALLBACK_KEY_UP : keyboard released.

func : callback function for key event.

data : use in func.

 

ex)

static void __key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
  Evas_Event_Key_Down *event = event_info;
   dlog_print(DLOG_INFO, LOG_TAG, "Key [%s]", event->keyname); // enter key's keyname = "Return"
}

evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_DOWN, __key_down, NULL);

output :

 Key Return

 

Dharmesh Guna

Thank you Alex & 연호 조,

I tried Alex's example using API evas_object_smart_callback_add(entry, "activated", entry_changed_cb, NULL);

And I achieved my purpose. I have one more question. Can we trigger these smart callback events using some APIs?

As an example: "Clicked" smart callback on a button widget.

Thank you.

연호 조

Hi,

try this.

 evas_object_smart_callback_call(obj, "Clicked", event_info);

Dharmesh Guna

Hi Yeonho Jo (연호 조),

Thanks a lot. It worked for me.

I passed NULL as event_info. evas_object_smart_callback_call(obj, "clicked", NULL);

Alex Dem

Hi,
just fyi, there is info what kind of signals button widget emits :
https://developer.tizen.org/dev-guide/2.3.0/org.tizen.guides/html/native/ui/ui_widgets_n.htm#button
Alexey.

Sung-Jin Park

Dear Dharmesh Guna, you can use key name(s) as you can see in Ubuntu and Fedora distribution(s).

Please refer to the following and enjoy Tizen !

 

You can see them by running the following command(s).

1. Run xev in the command line in Ubuntu or Fedora distribution(s).

2. Press any key.

3. Check the corresponding key name.

    This is an example by pressing enter key and then space bar.

    You can see the bold Return/space is the key name.

KeyPress event, serial 35, synthetic NO, window 0x4e00001,
    root 0xbd, subw 0x0, time 3889435252, (77,111), root:(555,685),
    state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
"   XLookupString gives 1 bytes: (0d) "
"   XmbLookupString gives 1 bytes: (0d) "
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x4e00001,
    root 0xbd, subw 0x0, time 3889435307, (77,111), root:(555,685),
    state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
"   XLookupString gives 1 bytes: (0d) "
    XFilterEvent returns: False

KeyPress event, serial 35, synthetic NO, window 0x4e00001,
    root 0xbd, subw 0x0, time 3889437096, (77,111), root:(555,685),
    state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
    XLookupString gives 1 bytes: (20) " "
    XmbLookupString gives 1 bytes: (20) " "
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x4e00001,
    root 0xbd, subw 0x0, time 3889437271, (77,111), root:(555,685),
    state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
    XLookupString gives 1 bytes: (20) " "
    XFilterEvent returns: False

Thanks and regards,

Sung-Jin Park