Generating event for entering and leaving object