How to limit a part in to a selected zone?

Well the question is hard to understand so check the picture below.

In this example

The cone shall be in its slot

However, when I pull it up

Isolated

When pull it down

Go into another part...

So my question is how to set a limit so the part can not exceed its position?

SolidworksAssemblies