If you have chosen to have the child object transform with the x and y positions of the parent then this will interfere with any independent movement of the child object.
If not, you can use instance variables to store the X and Y coordinates of the object and then use them to navigate back to.
For example.
On left click
- Set object var_x to self.x
- Set object var_y to self.y
- set position to mouse.x, mouse.y
On right click
- set position to self.var_x, self.var_y
If you want it to transform with the parent object and the parent object is also moving, you can still use variables to store the position but you would use distance and angle to the parent instead of self.x self.y.
For example.
On left click
- set object var_distance to [distance(parent.x,parent.y,self.x,self.y)]
- set object var_angle to [angle(parent.x,parent.y,self.x,self.y)]
- move to mouse.x, mouse.y
On right click
- Set position to
X: [parent.X+cos(self.var_angle)*self.var_distance] Y:[parent.Y+sin(self.var_angle)*self.var_distance]