Your suggestion works great for any icon item, whether in the titlebar or not.

Thanks