Simplify some code in handle_click_event.