Set the context before populating the menu. Fixes #640.