States in LVGL V8

Description

What MCU/Processor/Board and compiler are you using?

STM32f429/Custom Board/ STM32cubeide

What LVGL version are you using?

V8

What do you want to achieve?

Catch when a widget is released.

What have you tried so far?

Revied the documentation.
It seems that in the previous versions, there had been such a state, for example in version 7.11 there was an LV_BTN_STATE_RELEASED, which has been omitted in the present version. What has been added or implemented as an alternative?
The purpose is that it should not take the action when it is pressed (for example by touch screen) and then released the touchscreen in some locations other than over the widget (for example the widget here is a button). Of course, it should show that the button is clocked. Another, of course, is a slider for example which is an exception that should take into action when it is pressed.

I’m not 100% sure what the question is, but you should be able to replace LV_BTN_STATE_RELEASED with !lv_obj_has_state(btn, LV_STATE_PRESSED).

As far as I know, the same functionality should still exist in v8; it’s just that object-specific states were flattened into states which are shared by all objects.

The Document specifically says
" • LV_STATE_DEFAULT Normal, released state"
What is the difference between the above sentence and the code “!lv_obj_has_state(btn, LV_STATE_PRESSED)”
Mainly I am looking for some methods to catch “when” the widget is released after being clicked. Not to check if the widget is released or not.

States are just bit flags stored within an object. An object can have multiple states at once (e.g. pressed and checked). They are not exclusive values anymore like the object-specific ones were in v7.

LV_STATE_DEFAULT is a special constant used to indicate the default state (i.e. no other states are applied). However, you cannot use lv_obj_has_state on it as the result will always be true. Instead you have to check for the lack of the PRESSED state.

In that case, can’t you just use an event?

Exactly, I was looking for defining the event, but didn’t know how to define the event for releasing of a widget.

There is an LV_EVENT_RELEASED event which should be fired whenever a widget is released.

Sorry for misunderstanding, I hadnt read the documentation completely. Problem solved.

Glad I could help! :slightly_smiling_face: