generalized working with 2d buttons