add event handler

fix onpaint function