cancel
Showing results for 
Search instead for 
Did you mean: 

setDraggable() function

GMeur
Senior

Hi,

Why isn't there a function setDraggable() in the Drawable class, the same way there is a setTouchable() function ? (as of now, the setTouchable() serves too to prevent the dragEvents to be received by a given widget)

I'm asking because many times, I'd like my widgets to receive clickEvents but not dragEvents (that must be received by their parent containers).

Is there any reason for the lack of such a function?

Thanks.

3 REPLIES 3
Yoann KLEIN
ST Employee

Hello @GMeur​ ,

There are two main reasons why this functionality isn't implemented in the Drawable class :

  • When we developed that class some years ago, we didn't identified the need to implement it, because we were more interested into the clicking events that dragging ones.
  • We are always trying to minimize RAM usage and generated code size. So we just decided that, from a technical point of view, this feature was not important enough regarding of the cost in memory footprint.

Maybe you could give us a detailed example of an user case in which that function could be useful ?

Thanks,

/Yoann

Yoann KLEIN
ST Software Developer | TouchGFX
GMeur
Senior

Hi,

Thanks for your answer. An example would be a scrollablePagesContainer with a huge editable field in one page (that acts as a button). In that case, I don't want the dragEvents to be received by the editable field but by the scrollablePagesContainer. However, as I'm writing those lines, I realise it may not be that simple as I think the first ClickEvent must be received by both elements in order for them to work fine…

Indeed, it's exactly what I'm doing right now : I'm intercepting the dragEvents in the button and just passing them to its parent container (the scrollablePagesContainer), but I'm managing the ClickEvents differently as the first one is received by both the button and the scrollablePagesContainer (I copy it in the button and resent it) and after, I decide what to do with the release Event (send it to the button or to the scrollablePagesContainer depending on the delta of the drag).

Yoann KLEIN
ST Employee

Hello,

Thanks for your input.

I perfectly understand what you want to do, and why it could be useful to be able to separate Drag and Click events.

For the moment, we are not planning to implement that functionality.

I also think that your solution to redirect events based on the delta of the drag is a good way to determine if the user wants to click on the widget or drag it.

Sorry that I couldn't help you more,

/Yoann

Yoann KLEIN
ST Software Developer | TouchGFX