Skip to main content
Senior
May 22, 2025
Question

Nested Scrollbase

  • May 22, 2025
  • 5 replies
  • 682 views

I am trying put a ScrollWheelWithStyle inside a ScrollContainer.
Currently I can't find a method to pass down dragEvents from the Container to the Wheel.

I tried disabling the scrolling for the Container.
This cause the areas to initiate the draggable to be within the Wheel but the event is still handled by the Container.

I also tried to change the code found in "...\touchgfx\framework\include\touchgfx\containers\ScrollableContainer.hpp", that cause the application to crash in both Simulators.

Does anyone have recommendation on how to have nested Scrollables?

    This topic has been closed for replies.

    5 replies

    GGODA
    Associate II
    May 23, 2025

    Hello @Marc_LM ,

     

    I see 2 ways to do that.

    1. Create your elements as custom container
      I have tested it.
      Create your scrollableContainer and instead of adding your ScrollWheel, create a new custom container that is just your ScrollWheel, then add that custom container to your scrollableContainer
    2. Loop through your children and check if you clicked on one
      I have not tested this one, it will take mroe time to implement.
      When you start a drag with your finger, TouchGFX will first get a click event of type click, then it we get the drag and finaly when you release your finger it will get a click event of type release.
      So you can use the handleClickEvent, check whether it is a click or a release and if it is a click iterate through your children to see if you clicked on one of your children. If you do, change a value to true and set your scrollableContainer to not scrollable, also implement the handleDrageEvent to redirect the drag new X and new Y to your element.
      Then, we you get a release, set your scrollableContainer scrollable again.

    To see how to implement the second option, you can look at :

    1. the slider custom container to see how to use handleClickEvent and handleDragEvent
    2. this answer 's second code to see how to iterate through the children

     

    I hope this helps you.
    If it answers your question, I inivite you to select this post as "best answer".

     

    Regards,

    Marc_LMAuthor
    Senior
    May 23, 2025

    Thank you for the suggestion.
    I just tried to add a ScrollableContainer as a parent to the slide (example 1).
    It too suffers from what I see were the ScrollableContainer starts to drag .
    The ScrollableContainer is the culprit that does not propagate the click/drag to its children properly.
    I'll take this into advice and remake a new ScrollableContainer.


    Side note:
    @GaetanGodart, I noticed a bug in the slider. I can just click at the right of it and it will trigger its completion. No sliding required. Not sure I will have time to send you a patched version to explain the bug.

    Marc_LMAuthor
    Senior
    May 23, 2025

    I could not change the ScrollableContainer itself but after cloning it and modding it, I nearly got something reasonable where click/drag propagate to children first.

    If anyone know how to check if "handle*Event", is processed or not by their children.
    I could use that check to enable dragging to children who do not handle them.
    Looked into uninitialized vTable entries for object, but all reference discourages as being non-portable.
    Any alternative would be welcome.

    I am attaching the changed .hpp/.cpp for posterity.

    Billy OWEN
    ST Employee
    May 27, 2025

    Hi @Marc_LM 

     

    This post has been escalated to the ST Online Support Team for additional assistance.  We'll contact you directly.

     

    Regards,

    Billy