How to achieve the effect about click a button object and move the position?

Button object, List object

I want to achieve this effect:
When I keep clicking on a button object with the mouse, if there is a moving position, do not update the click effect. I want to know if there is a good way to achieve this?

The code like this:

lv_obj_t *button = lv_btn_create(lv_scr_act(), NULL);
lv_obj_align(button, NULL, LV_ALIGN_CENTER, 0, 0);

The state: pressed, clicked, pressing
a moving position:

lv_point_t vect;
lv_indev_get_point(lv_indev_get_act(), &vect);
bool moving_flag = (bool)(vect.x > 0 || vect.y > 0);

In other words, when move the position on the button, the style LV_BTN_STATE_PR is not refreshed, when click the button without moving, the style LV_BTN_STATE_PR is refreshed.

I am looking forward to your good ideas.

I don’t completely understand what you’re trying to achieve here. It sounds like you are asking for the button’s state to not change while you are dragging it?

I’m also not sure I understand correctly but buttons lose their pressed state only when they are dragged. So without lv_obj_set_drag(btn, true) they should keep the presses state even if you move your finger/mouse on them while pressing.

YES. That’s about it.

Yes, you are right, that’s about it.

I actually applied it on the list object.

When the button(list item object) is dragging on pressing, I dont’s want to refresh the button pressed state, but when click the button without dragging, it should keep the pressed state.

I think I understand now.

  • You want a list of toggle buttons.
  • If you scroll the list, the button should not remain toggled when you release your finger.
  • If you just touch the button, it should toggle.

When I scroll the list, the button should not refresh the button pressed state.

There is no configuration option for it right now.
What advantage do you see in “keeping pressed while scrolling” behavior?
If we find it better it can be changed in the library.

Thank you for your reply. I think that it’s okay now.

Best regards.