Fix #1797, with awareness of widget visibility.
Merge pull request #1814 from AnalyticalGraphicsInc/issue1797

Fix #1797, with awareness of widget visibility.