Hello all,
my paintings app is evolving into some sort of point and click thingy and I have one small problem to solve.
Each painting has several children, clickable areas that will trigger some actions.
The user can zoom into the painting and then move it around to have a closer look. I do not want a clickable area to register input should the cursor happen to rest on it when moving the parent has completed and the mouse is released (while the parent is moving and the mouse is pressed, everything works as intended).
I would like to solve this with the use of flags, searched to forum but could not produce code that works.
This is what I’ve got so far, obviously not working:
if action_id == hash("touch") then
-- fill movement array
table.insert(actions_array_x, action.x)
table.insert(actions_array_y, action.y)
if gui.pick_node(image, action.x, action.y) then
if image_scale == zoom_limit_lower then
gui.set_position(image, vmath.vector3(0, 0, 0))
end
-- allow moving the image only when the image is scaled
if action.pressed and image_scale > zoom_limit_lower then
print("image pressed")
image_moving = true
elseif action.released then
print("image released")
image_moving = false
reset_movement_variables()
end
if image_moving == true then
calculate_movement()
calculate_boundary()
position_image()
end
end
if image_moving == false then
for i = 1, #buttons_array do
local button = buttons_array[i]
-- runs when the cursor is on the button after the moving of the image is completed
if gui.pick_node(button, action.x, action.y) then
-- prints when the image is scaled
print("button"..i.." picked")
if action.pressed then
-- does not print when the image is scaled
print("button"..i.." pressed")
elseif action.released then
-- prints when the image is scaled
print("button"..i.." released")
end
end
end
end
end
If someone could point me into the right direction, I would be very grateful.