{"action":"created","issue":{"url":"https://api.github.com/repos/littlevgl/lvgl/issues/945","repository_url":"https://api.github.com/repos/littlevgl/lvgl","labels_url":"https://api.github.com/repos/littlevgl/lvgl/issues/945/labels{/name}","comments_url":"https://api.github.com/repos/littlevgl/lvgl/issues/945/comments","events_url":"https://api.github.com/repos/littlevgl/lvgl/issues/945/events","html_url":"https://github.com/littlevgl/lvgl/issues/945","id":421493316,"node_id":"MDU6SXNzdWU0MjE0OTMzMTY=","number":945,"title":"Notification from text area when the Enter key is hit – 6.0 version","user":{"login":"manison","id":2073329,"node_id":"MDQ6VXNlcjIwNzMzMjk=","avatar_url":"https://avatars3.githubusercontent.com/u/2073329?v=4","gravatar_id":"","url":"https://api.github.com/users/manison","html_url":"https://github.com/manison","followers_url":"https://api.github.com/users/manison/followers","following_url":"https://api.github.com/users/manison/following{/other_user}","gists_url":"https://api.github.com/users/manison/gists{/gist_id}","starred_url":"https://api.github.com/users/manison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manison/subscriptions","organizations_url":"https://api.github.com/users/manison/orgs","repos_url":"https://api.github.com/users/manison/repos","events_url":"https://api.github.com/users/manison/events{/privacy}","received_events_url":"https://api.github.com/users/manison/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2019-03-15T12:22:30Z","updated_at":"2019-03-18T09:30:20Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I'm trying to rewrite the solution from #754 from signal based to the new event based interface introduced in 6.0 version, but I'm hitting some issues.\r\n\r\nMy original signal handler looks like this:\r\n\r\n```c\r\nstatic lv_res_t TextArea_OnSignal(lv_obj_t *obj, lv_signal_t sign, void *param)\r\n{\r\n    if (sign == LV_SIGNAL_CONTROLL) {\r\n        uint32_t c = *((uint32_t *)param);\r\n        if (c == '\\n' || c == '\\r')\r\n            TextArea_OnEnterKeyPress(obj);\r\n    }\r\n    return TextAreaOriginalSignalFunc(obj, sign, param);\r\n}\r\n```\r\n\r\nNow the first change in 6.0 is that Enter key no longer generates `LV_SIGNAL_CONTROLL` signal but `LV_SIGNAL_PRESSED` is raised instead. `LV_SIGNAL_PRESSED` can be also generated by encoder or pointer devices but I only need to respond to keypad devices. I tried to take advantage of the new event based mechanism and thought that the event handler below does the trick:\r\n\r\n```c\r\nlv_res_t TextArea_OnEvent(lv_obj_t *obj, lv_event_t e)\r\n{\r\n    lv_indev_t *indev;\r\n    if (e == LV_EVENT_PRESSED &&\r\n       (indev = lv_indev_get_act()) != NULL &&\r\n       lv_indev_get_key(indev) == LV_GROUP_KEY_ENTER)\r\n    {\r\n        TextArea_OnEnterKeyPress(obj);\r\n    }\r\n    return LV_RES_OK;\r\n}\r\n```\r\n\r\nThe problem with this is that `lv_indev_get_key` returns the **previously** pressed key instead the actual key that generated the event.\r\n\r\nThe comment for `lv_indev_get_key` really says \"*return the last pressed key (0 on error)*\" so this is probably intentional behavior. But I can't imagine this behavior could be useful. IMHO it should be changed to \r\n* returns the actual key being pressed when called in the context of LV_EVENT_PRESSED event handler\r\n* returns the last pressed key if called outside the event handler\r\n* returns 0 on error\r\n\r\nWhat do you think?"},"comment":{"url":"https://api.github.com/repos/littlevgl/lvgl/issues/comments/473833672","html_url":"https://github.com/littlevgl/lvgl/issues/945#issuecomment-473833672","issue_url":"https://api.github.com/repos/littlevgl/lvgl/issues/945","id":473833672,"node_id":"MDEyOklzc3VlQ29tbWVudDQ3MzgzMzY3Mg==","user":{"login":"manison","id":2073329,"node_id":"MDQ6VXNlcjIwNzMzMjk=","avatar_url":"https://avatars3.githubusercontent.com/u/2073329?v=4","gravatar_id":"","url":"https://api.github.com/users/manison","html_url":"https://github.com/manison","followers_url":"https://api.github.com/users/manison/followers","following_url":"https://api.github.com/users/manison/following{/other_user}","gists_url":"https://api.github.com/users/manison/gists{/gist_id}","starred_url":"https://api.github.com/users/manison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manison/subscriptions","organizations_url":"https://api.github.com/users/manison/orgs","repos_url":"https://api.github.com/users/manison/repos","events_url":"https://api.github.com/users/manison/events{/privacy}","received_events_url":"https://api.github.com/users/manison/received_events","type":"User","site_admin":false},"created_at":"2019-03-18T09:30:20Z","updated_at":"2019-03-18T09:30:20Z","author_association":"CONTRIBUTOR","body":"> I've also fixed lv_indev_get_key in dev_6.0.\r\n\r\nSeems to work as suggested, thanks.\r\n\r\nAt the end I realized I cannot use events in this case. I need to eat the Enter key and prevent it to reach the object. In event it is too late, the `\\n` char is already added to the text area. So it seems I'm stuck with the signals.\r\n\r\nOT: I always wondered why the signal is called LV_SIGNAL_CONTROL**L** Does the second _L_ mean anything or is it a typo?"}}
{"actor":{"display_login":"manison"}}