Ensure event listener is a widget before casting #13130

Change-Id: I7f106356116d73eebbfeeee52d61d8d7a7117b3e