FellippeHeitor / InForm

A GUI engine and WYSIWYG interface designer for QB64
MIT License
61 stars 15 forks source link

Tooltip positioning error #2

Closed Ron-Burr closed 7 years ago

Ron-Burr commented 7 years ago

In the current InForm.ui hover detection process, when the calculated print width of a Tooltip exceeds the current mouse position plus the width of the FormID, the __UI_ActiveTipLeft position is reset to the width of the FormID minus the width of the Tooltip, which can sometimes result in a position farther left than the left margin of the FormID. When that happens, a portion of the left side of the Tooltip pane is not visable. In a different place in InForm.ui, the print width of the Tooltip is calculated based on the width of a panel containing the Tooltip after it has been "word-wrapped" - and, if the word-wrapped text requires more than one line, the calculated width will always be narrower than the print width that was computed in the hover detection process. Therefore, I would suggest that the code in the hover detection process be modified to replicate that which is used when actually formatting the Tooltip for display. To wit:

'Check if a tooltip must be enabled
IF __UI_HoveringID <> __UI_LastHoveringID OR __UI_MouseButton1 OR __UI_MouseButton2 THEN
    __UI_TipTimer = TIMER
    __UI_ActiveTipID = 0
    __UI_ActiveTipTop = -1
    __UI_ActiveTipLeft = -1
    ELSE
    IF __UI_HoveringID > 0 AND NOT __UI_IsDragging THEN
        IF TIMER - __UI_TipTimer >= .8 THEN
            IF LEN(ToolTip(__UI_HoveringID)) > 0 THEN
                __UI_ActiveTipID = __UI_HoveringID
                _FONT Control(__UI_FormID).Font
                IF __UI_ActiveTipTop = -1 THEN
                    __UI_ActiveTipTop = __UI_MouseTop + 16
                    IF __UI_ActiveTipTop + uspacing& * 1.5 > Control(__UI_FormID).Height THEN
                        __UI_ActiveTipTop = __UI_MouseTop - uspacing& * 1.5
                    END IF
                END IF
                IF __UI_ActiveTipLeft = -1 THEN
                    __UI_ActiveTipLeft = __UI_MouseLeft
                    TempCaption$ = __UI_WordWrap(ToolTip(__UI_ActiveTipID), Control(__UI_FormID).Width / 3, TotalLines)
                    IF TotalLines = 1 THEN
                        PanelWidth = __UI_PrintWidth(TempCaption$) + 10
                    ELSE
                        PanelWidth = Control(__UI_FormID).Width / 3 + 10
                    END IF
                    IF __UI_ActiveTipLeft + PanelWidth > Control(__UI_FormID).Width THEN
                        __UI_ActiveTipLeft = Control(__UI_FormID).Width - PanelWidth
                    END IF
                END IF
            END IF
        END IF
    ELSE
        __UI_ActiveTipID = 0
        __UI_ActiveTipTop = -1
        __UI_ActiveTipLeft = -1
    END IF
END IF
FellippeHeitor commented 7 years ago

I'll give your fix a try and let you know. Thanks for the report!

FellippeHeitor commented 7 years ago

Hi Ron-Burr. The issue has been fixed with the changes introduced in commit 5a666b0. Please check it out and let me know how it works for you now. Again, thanks for reporting.

Ron-Burr commented 7 years ago

The update works well. Thanks.