Drag a TEXT comp into a zone

Hi,

I’m doing an interactive installation where people need to drag words into 3 differents boxes (zones in my UI).

I acheived to drag my text comps in my UI. But I have no idea how to detect a text COMP in a specific zone in my UI.

I tried to use drag and drop feature but I think it only work if you drag a node in the active window of a another node and this is not what I want. I want to have a UI that make all my screen where people can choose in a list of words and drag them in a zone to ‘‘select them’’ Then I need to know wich word is it.

I dont know if it is clear. I tried to do my own research but I could find what I’m looking for. Any info to guide me would be helpful.

Thank you
LP

Hi @louislp19,

can you share your basic setup or describe in greater detail?
How are the zones defined that people are suppose to drag the words to? Are those Container COMPs perhaps that could have a callback for when something was dropped onto them?

cheers
Markus

Thank you @snaut for your answer. Here is my project to it’s simplest.

I have a UI with multiple words. Users will move them with a touch screen but for now we can drag them with the mouse.

The goal is know what word has been move in the box in the center. So I will need a variable with the text name.

Let me know if this is not clear.
Thank you
TOUCH_MOTS_STATION.toe (6.1 KB)

Hi @louislp19,

in this case you are actually not dragging but repositioning the component. There is a Panel Value “reposition” that goes to 1 for the component which you are moving.

To make this work, use a Panel Execute DAT and watch the “reposition” Panel Value of the Text COMPs. In the onOnToOff callback, now check if the “inside” Panel Value of your drop area is on and trigger the action you would like to see happening. The name/path/reference of the repositioned operator can be retrieved from the panelValue argument to the callback: panelValue.owner

hope this helps
cheers
Markus
TOUCH_MOTS_STATION.toe (6.1 KB)

Hi, @snaut

your exemple is working great and you help me a lot. I have a new question about this project. I need to know when a text is currently inside the box or not inside.

For now, if I drop a text inside, I can trigger something when a new word is drop inside. But it cannot detect when I remove it and it is empty.

Here is my new file, I have 6 zones and I have 6 words, users need to put the words in the boxes that want to create a sentence. I need to know when a box have a word in it and when it is empty.

Hope this is clear.
Thank you
TOUCH_MOTS_STATION.toe (219.6 KB)

Hi @louislp19,

currently you are saving which text index is placed in which zone, making it a bit more difficult to clear the values when the text is removed. Instead you could save what zone the text is being dropped in and do it all in a single Panel Execute DAT:

def onOnToOff(panelValue):
	# get the digit of the text being dragged
	mot = panelValue.owner.digits
	# loop over all zones and see if the mouse is inside that panel
	for i in range(1,7):
		if op('Drop_zone{}'.format(i)).panel.inside:
			op('index_motZone').par['const{}value'.format(mot-1)] = i
			# if a zone is found, exit this function
			return
	# if no zone was found, set the text's zone index to 0
	op('index_motZone').par['const{}value'.format(mot-1)] = 0
	return

cheers
Markus
TOUCH_MOTS_STATION.51.toe (222.2 KB)