Thanks again Robert, you've helped me a lot over the past week or so.
This works perfectly when the widget is closed and the icon is clicked to re-open it.
But it looks like the event isn't fired when the widget is already loaded. Is there another event that might work??