how to have draggables inside a viewport be brought outside to put on a droppable?
Posted: Fri Jul 30, 2021 1:51 am
Hi! I'm trying to make a drag and drop system that takes the draggable object from a scrollable viewport and onto a outside droppable area. To make it clear, here is the layout currently:
The black square with a question mark is the area I want to be able to put the square with a smiling lad on to. Afterwards, the "? is on ?!" turns into "person is on spot!", which I use to test the variables are working. In previous tests where there was no viewport, this works perfectly fine. however, with the draggable object inside the viewport, it cannot escape the frame it is inside. Here is the code inside the init python block:
and here is the code inside the screen. Do note that this screen is inside a menu.
I am only putting the draggable objects into a viewport to be able to scroll through future added draggable objects. If there is some other way to have a scrollable area without all this headache, that would be a great alternative.
Thank you for reading!! I have been utterly confused with this for a while.
The black square with a question mark is the area I want to be able to put the square with a smiling lad on to. Afterwards, the "? is on ?!" turns into "person is on spot!", which I use to test the variables are working. In previous tests where there was no viewport, this works perfectly fine. however, with the draggable object inside the viewport, it cannot escape the frame it is inside. Here is the code inside the init python block:
Code: Select all
init python:
def unit_dragged(drags, drop):
if drop:
drags[0].snap(drop.x,drop.y)
store.person = drags[0].drag_name
store.spot = drop.drag_name
return
if not drop:
drags[0].snap( 5, 5)
return
Code: Select all
screen vcs:
tag menu
use evi_menu(_("VCS")):
hbox:
yalign 0.1
xalign 0.0
add "cam" # the background image of the woman.
frame:
area (0, 450, 700, 200)
viewport id "vp":
scrollbars "vertical"
mousewheel True
draggable True
side_yfill True
vbox:
draggroup:
drag:
drag_name "movable"
child "icon1_idle.png"
ypos 5
dragged unit_dragged
droppable False
xpos 5
vbar value YScrollValue("vp")
drag:
drag_name "postion"
child "whoisit.png"
draggable False
droppable True
yalign 0.27
xalign 0.28
frame:
xsize 200
ysize 650
yalign 0.27
xalign 0.99
xpadding 10
ypadding 10
text "[person] is on [spot]!"
Thank you for reading!! I have been utterly confused with this for a while.