add missing onenter and onafter handling

implemented as documented. tests added.