Refreshing of SuperTooltip
|Reported by:||Adamb||Owned by:|
First of all - SuperTooltip is a nice feature, that deserves giving it a try. However, looks like it needs bit of fresh air, so here it comes (Get yourself a pack of popcorn and enjoy reading!):
SuperTooltip, or The Sum of All Fears:
- Shadows and rounded corners are available on windows later than XP, so checking for an exact OS version restricts tooltip too much. Patch changes it, checking if OS is later than XP
- ToolTipWindowBase.CalculateBestSize is almost a copy of ToolTipWindowBase.OnPaint - a tiny change to the latter makes CalculcateBestSize fit within 2 lines instead of ~80.
- Speaking about ToolTipWindowBase.OnPaint - it's spanning over 150 lines and has numerous repetitions, making it harder to read and/or change behaviour in subclass. Patch slightly improves method readability.
- There's a method SuperToolTip.DoShowNow() for instant display of tooltip, but there's no 'DoHide()' method for instant closing it. Patch adds a DoCloseNow() method. Naming was chosen to be consistent with DoShowNow()
- EVT_KILL_FOCUS is bound to tooltip window itself. Maybe it has some reason I can't see (tooltip on wx.MSW doesn't seem to have focus at all). However it seems most reasonable to bind handler to EVT_KILL_FOCUS emitted by a parent of tooltip, so when tooltip is shown and user pressses ALT+Tab, tooltip can be destroyed. Currently it just remains visible, even when its parent is hidden. Patch actually replaces current binding of EVT_KILL_FOCUS with one to parent, but as I said - maybe it's not an error and there's some reason EVT_KILL_FOCUS on tooltip should be handled (Mac or GTK port may behave differently).
- Tooltip body text can contain a link. But how user is supposed to click it, since tooltip disappears whenever mouse cursor leaves widget area and tooltip is displayed outside this area? My patch does nothing with this, because it's not clear to me what behaviour would be correct here. Displaying tooltip next to mouse cursor seems like a good idea, but it changes behaviour, so I want someone to confirm that it should be done that way. Actually, due to issues 5. and 7., user can hide widget and then move mouse onto visible tooltip to click a link, but well... it's a hack, not a feature
- TooltipWindowBase.OnWidgetLeave ignores events which take place inside widget rectangle, so when widget is partially obscured by some other window and user moves mouse over that other window - tooltip is still shown. Patch fixes it.
- SuperToolTip.EnableTip doesn't stop self._startTimer, so tooltip can be still shown if SuperToolTip.EnableTip(False) has been called after ToolTipWindowBase.OnWidgetEnter() has been processed. Patch fixes that.
- There's no way to check if tip is enabled outside of SuperToolTip class. Patch adds IsEnabled() method that returns boolean value.