Refactor link widget with tidier event handler