But now I get the weirdest of behaviour: the newly swapped in button also gets clicked event!
So I click once on an object, and in the onclick event for that object, swap the objects X&Y with a completely differetn object, and the new object also gets an onclick event, even though there has been no click on the second object.
Is this a bug do you think?
Nah, it's just that when you click the mouse it will go through all the click events on the event sheet. It checks event 1, sees you've clicked on button 1 and then hides that button and moves button 2 into place. Then it checks event 2 and now button 2 is below the mouse so it counts as a click on it, even though it wasn't there when you first clicked.
This came up before when someone wanted to show a box by clicking a button and then hide it by clicking on the box. The solution was to toggle a variable with the mouse clicks and then toggle the objects visibility based on the variable. You have to seperate it so the mouse clicks don't interfere with each other.
toggleMenu.capx (r99)
Yann's method is better for a toggle button.