Generalize widget handling