added additional check for handling gadgets from button events