Is there a rule about the use of "when" and "while" for past continuous and simple past? I am confused.
When means that one action took place after another. Both actions are described in Past Simple tense (the earlier could also be described in Past Perfect)
When Jack [had] finished his homework, he went out to play football with his friends.
The word had in brackets means that this action may be described in Past Simple (finished) or Past Perfect (had finished).
While means that one action took place in the same time as the other (often interrupting it). The longer action is expressed by Past Continuous. The other is usually in Past Simple.
While we were eating dinner, the telephone rang.
This sentence means that while we were in the middle of one action (eating dinner), the other (shorter) action took place (here the telephone rang).