I'm not a diving expert, but I've had a bit of training in handling "emergency" situations. (27 years on fire dept, a couple of decades as a lifeguard and lifeguard trainer, etc...) Your response goes beyond merely practicing a specific skill, though that is a great way of leaning to handle that specific situation. I'm reminded of what pilot instructors tell their trainees all the time about handling an airborn emergency. "1) First, get control of the aircraft 2) Analyze and isolate the problem 3) Execute a carefully thought-out plan of action".
In essence, that's what we're taught as divers. Breath, assess, act (as many other posters pointed out). Somewhere in your response to a flooded mask, your mind should have provided important data. "Okay, my mask is flooded. I'm still breathing, so what should I do next?" Then your training should take over. You could remove the mask, put it back on, and attempt clearing it. You could attempt a slow ascent with a flooded mask. You could attempt to contact your partner and allow him/her to assist with either or both of the above. But above all else, you needed to keep a clear, rational perspective so that you could consciously think about your options. Controlling panic is a state of mind you work on long before an emergency situation pops up. Practicing skills is great; it helps you know what you should do in a situation. But being ready for an emergency means being mentally prepared and cognizant that those situations can crop up anytime and your response should be to get calmer, not more excited.
This was, as you pointed out, a great learning opportunty. Congratulations on the insights you have gained through it. Keep diving, and have fun underwater!