I could see my 3.5 year old doing this, if she would talk to other kids. She is - and always has been - food obsessed. It would be a very rare occurrence that she'd prioritize something else over food.
I think you did the right thing. I'd explain that it puts others (kids and adults alike) in an uncomfortable position. That their comfort is important too, and if she keeps ignoring others' feelings then you won't let her play with them.
Otherwise just the usual - keep up your messages about sometimes foods and that she needs to ask you - not them - for food.