I am making an app where the user inputs some text, which then moves with a box it was “assigned”. While moving it changed itself to another object, so that the selection will work. It all works fine to this point. The problem I have is I cannot change the text back to normal even though I do the same thing as before.
If you have problem understanding, it’s something like this:
Basically everything works fine but the final text. When I tried creating a variable which would equal the drag text, it also returned 0 or nothing.
Here is my code for this:
Now the same but with my problem:
What you’re doing seems a tad convoluted. I’d suggest the following:
add a sticky behaviour to the newtext object.
when you create dragtext, don’t delete newtext. Hide newtext, and stick it to dragtext
when mouse is released, unstick newtext, show it and delete dragtext.
No need to copy values back and forth, or it delete and recreate objects.
I tried using the sticky behaviour, it’s very buggy and I don’t know why,
I tried simplifying it and it almost works, just almost.
This is the code I now use
The problem now is that newtext (the actual text) doesn’t follow the dragtext until it touched the mainlistdrag in a very specific location.
It is also sometimes prone to just not following it and I need to make it follow the object again.
There’s no sticker action in that one. Also, why don’t you use the draggable object behaviour?
Here’s a little example I rustled up. Is it similar to what you’re after? The dragtext object has the sticker behaviour attached, the newtext object has the draggable object behaviour attached:
Which results in:
Ok, it finally worked, I don’t know why it didn’t work the first time when I used the sticker behaviour though, as the code isn’t relly different from what I tried