-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LV_EVENT_CLICKED should only be fired if the release takes place over the same object where the press happened #6229
Comments
Viatorus
changed the title
LV_EVENT_CLICKED should only fire if released happens over the same object where pressed happend
LV_EVENT_CLICKED should only be fired if the release takes place over the same object where the press happend
May 15, 2024
Viatorus
changed the title
LV_EVENT_CLICKED should only be fired if the release takes place over the same object where the press happend
LV_EVENT_CLICKED should only be fired if the release takes place over the same object where the press happened
May 15, 2024
I confirmed this is still a thing in the latest C equivalent for referencestatic void cl_cb(lv_event_t * e)
{
LV_LOG_USER("clicked");
}
static void click_scroll(void)
{
lv_obj_t * btn = lv_button_create(lv_screen_active());
lv_obj_align(btn, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event_cb(btn, cl_cb, LV_EVENT_CLICKED, NULL);
lv_label_set_text(lv_label_create(btn), "Hello World!");
} list of buttons in Micropython# Initialize
import display_driver
import lvgl as lv
# Create a button with a label
def make_cb(i):
return lambda e: print("Clicked", i)
scr = lv.obj()
scr.set_flex_flow(lv.FLEX_FLOW.COLUMN)
for i in range(20):
btn = lv.button(scr)
btn.align(lv.ALIGN.CENTER, 0, 0)
btn.add_event_cb(make_cb(i), lv.EVENT.CLICKED, None)
label = lv.label(btn)
label.set_text(str(i).center(20))
lv.screen_load(scr) This change in lv_indev.c seems to give the desired effect. On release, if we did not scroll, and we're still over the object, send the click. @kisvegabor, is a PR in order? diff --git a/src/indev/lv_indev.c b/src/indev/lv_indev.c
index 08ff5be07..e18b81d14 100644
--- a/src/indev/lv_indev.c
+++ b/src/indev/lv_indev.c
@@ -1310,7 +1310,7 @@ static void indev_proc_release(lv_indev_t * indev)
}
if(is_enabled) {
- if(scroll_obj == NULL) {
+ if(scroll_obj == NULL && lv_obj_hit_test(indev_obj_act, &indev->pointer.act_point)) {
if(indev->long_pr_sent == 0) {
if(send_event(LV_EVENT_SHORT_CLICKED, indev_act) == LV_RESULT_INVALID) return;
} |
Hi, It can be controlled by btn.remove_flag(btn.FLAG.PRESS_LOCK) |
Oh, thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LVGL version
9.0.0
What happened?
If a user tries to scroll although scrolling is not possible, unwanted click events occur at the point where the user started scrolling. Even though, the release position happend at a different object.
Think on a list of buttons which is sometimes scrollable, sometimes not.
I don't know of such behavior anywhere on Windows, Linux, Web or Android. If you leave the clickable, no click will happen.
P.S. Thank you for already fixing this: #5660
How to reproduce?
Run the code below.
Press the button, than leave the button area and release the mouse. "Clicked" will is printed in the console.
Simulator: https://sim.lvgl.io/v9.0/micropython/ports/webassembly/index.html
The text was updated successfully, but these errors were encountered: