Prevent auto toggle on long press with checkable panel in SquareLine Studio

Hi,

I’m using SquareLine Studio to design a panel that acts like a button.

  • The panel has Checkable and Clickable enabled.
  • Click short → toggle ON/OFF state of the lamp (checked/unchecked).
  • Long press → switch to another screen for lamp detail settings.

The problem:
When I long press, the LV_EVENT_LONG_PRESSED event is triggered correctly (screen switch works), but after I release the touch, LV_EVENT_CLICKED is still fired and the panel state toggles. This causes unwanted toggle when I only want to enter the detail screen.

Question:
How can I prevent the toggle (check/uncheck) when long press happens, while keeping the toggle for short clicks?

Hi, this is the expected default behavior in LVGL. When you long-press and then release a widget, both the LV_EVENT_LONG_PRESSED and LV_EVENT_CLICKED events are triggered.

The simplest and most user-friendly solution is to separate these two actions. You could use the short click on the panel to toggle the state and add a separate settings icon or button to navigate to the details screen.

If you must keep the original design, you will need to implement custom logic. Instead of using the built-in actions in SquareLine Studio, use the “Call Function” action for both the click and long-press events. In your C code, you can then create a flag. When the long-press function is called, set the flag. In the click function, first check the status of this flag. If the flag is set (meaning a long press just occurred), simply reset the flag and do not toggle the state. If the flag is not set, proceed with the toggle action as it was a normal short click.