2024-02-26 06:51 PM
I am working on a feature related to DragEvent. The goal is to detect when a certain container has been pressed for a few seconds, after which it would proportionally enlarge and become draggable. During the dragging process, if it encounters other containers, those containers should automatically move aside, left and right, similar to the behavior on an iPhone. Is this feasible to implement in TouchGFX? Or is there already a related post that I might have missed?
Note: The mentioned containers are clickable and can change screens.
Sorry if this is a simple question.
2024-03-03 11:51 PM
Hello @aaaa ,
It's feasible in TouchGFX but it requires some work, I'll try to give you an idea on how it can be implemented.
1) You may take to look at this post for the long press handling : Solved: How to detect long press on custom container? - STMicroelectronics Community, for the draggable part you can check the handleTick ,handleClick and handleDrag events, and do something like :
MyContainer::handleDragEvent(const DragEvent &ev)
{
if (!canBeDrag){
// keep the same position
}
}
MyContainer::handleTickEvent()
{
if (count>tickToBeDrag){
canBeDrag = true;
}
}
MyContainer::handleClickEvent(const ClickEvent &ev)
{
if (ev.getType() == ClickEventType::CANCEL){
canBeDrag = false;
count = 0;
}
}
So here after count reaches the tick limit, we set a bool to true that will allow us to drag our container.
2) For the size change you can use Scalable Image | TouchGFX Documentation, to change the image size's once it's dragged.
3) And for the moving behaviour, you will need to keep the track of all the containers in a list or something in order to know when a container encounters another. Since they are all the same size and you will know their positions, it's easier to know which one you need to move to make space for the dragged container.
I hope it helps,
Regards,
2024-03-21 04:05 AM
Hello @aaaa ,
Were you able to create the effect you wanted ?
Regards,
2024-03-28 09:04 PM
Thank you for your reply, @LouisB.
As I have just recovered from a serious illness, I will need some time to study your suggestions. I will get back to you if there are any developments, but the progress will likely be very slow. Since my project no longer requires this feature after returning to my work position, I need to focus on other work goals first.
Nevertheless, I am very grateful for your advice!
2024-04-02 12:41 AM - edited 2024-04-02 12:41 AM
Hello @aaaa,
Glad to hear that you are going better, if you have any other question feel free to ask. Also, if you find that my suggestion answers to this topic, you can but it as the best solution for the others to find it easily.
Best regards,