Refactoring: psw-popup-menu function generalized.