Jump to content

Displaying lots of information in a tooltip


Phenom
 Share

Recommended Posts

I have a lot of information I want to display in a tooltip. I requires several lines. I do not want to have to put all of it in one line, because it's long. If I split the command along multiple lines then it's not recognized. How can this be done?

Link to comment
Share on other sites

I use this function in SMF...

Func _ToolTip_Wrap_Long_String($s_ToolTip_Org)
    Local $s_ToolTip_Final
    Local $s_ToolTip_Work = $s_ToolTip_Org
    Local $i_ToolTip_Max_StringLen = 120
    Local $i_ToolTip_Max_Rows = 8
    Local $i_ToolTip_Current_Rows = 0
    If StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen Then
        While StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen
            $s_ToolTip_Final &= StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen) & @LF
            $s_ToolTip_Work = StringRight($s_ToolTip_Work, StringLen($s_ToolTip_Work) - $i_ToolTip_Max_StringLen)
            $i_ToolTip_Current_Rows += 1
            If $i_ToolTip_Current_Rows = $i_ToolTip_Max_Rows - 1 Then
                $s_ToolTip_Work = StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen - 4) & " ..."
                ExitLoop
            EndIf
        WEnd
        $s_ToolTip_Final &= $s_ToolTip_Work
    Else
        $s_ToolTip_Final = $s_ToolTip_Work
    EndIf
    StringStripWS($s_ToolTip_Final, 7)
    ToolTip($s_ToolTip_Final)
EndFunc   ;==>_ToolTip_Wrap_Long_String
Link to comment
Share on other sites

I use this function in SMF...

Func _ToolTip_Wrap_Long_String($s_ToolTip_Org)
    Local $s_ToolTip_Final
    Local $s_ToolTip_Work = $s_ToolTip_Org
    Local $i_ToolTip_Max_StringLen = 120
    Local $i_ToolTip_Max_Rows = 8
    Local $i_ToolTip_Current_Rows = 0
    If StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen Then
        While StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen
            $s_ToolTip_Final &= StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen) & @LF
            $s_ToolTip_Work = StringRight($s_ToolTip_Work, StringLen($s_ToolTip_Work) - $i_ToolTip_Max_StringLen)
            $i_ToolTip_Current_Rows += 1
            If $i_ToolTip_Current_Rows = $i_ToolTip_Max_Rows - 1 Then
                $s_ToolTip_Work = StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen - 4) & " ..."
                ExitLoop
            EndIf
        WEnd
        $s_ToolTip_Final &= $s_ToolTip_Work
    Else
        $s_ToolTip_Final = $s_ToolTip_Work
    EndIf
    StringStripWS($s_ToolTip_Final, 7)
    ToolTip($s_ToolTip_Final)
EndFunc   ;==>_ToolTip_Wrap_Long_String

How do you call that? Do you just pass the long string? That's the problem. You have to put the long string all in one line.
Link to comment
Share on other sites

It works well with multiple lines !

$_message = 'I have a lot of information ' & @CRLF & _
            'I want to display in a tooltip.' & @CRLF & _
            'I requires several lines.' & @CRLF & _
            'I do not want to have to put all of it in one line, because its long.' & @CRLF & _
            'If I split the command along multiple lines then its not recognized.' & @CRLF & _
            'How can this be done?' 

Tooltip ( $_message )
Sleep ( 5000 )

Show us how you use tooltip...

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I use it like shown belown. Wraps the tooltip and cuts it to a max length, useful if you don't know the length of the string beforehand ;)...

$string =   "aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
$string &= "aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
$string &= "aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"

_ToolTip_Wrap_Long_String($string)

sleep(10000)

Func _ToolTip_Wrap_Long_String($s_ToolTip_Org)
    Local $s_ToolTip_Final
    Local $s_ToolTip_Work = $s_ToolTip_Org
    Local $i_ToolTip_Max_StringLen = 120
    Local $i_ToolTip_Max_Rows = 8
    Local $i_ToolTip_Current_Rows = 0
    If StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen Then
        While StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen
            $s_ToolTip_Final &= StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen) & @crlf
            $s_ToolTip_Work = StringRight($s_ToolTip_Work, StringLen($s_ToolTip_Work) - $i_ToolTip_Max_StringLen)
            $i_ToolTip_Current_Rows += 1
            If $i_ToolTip_Current_Rows = $i_ToolTip_Max_Rows - 1 Then
                $s_ToolTip_Work = StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen - 4) & " ..."
                ExitLoop
            EndIf
        WEnd
        $s_ToolTip_Final &= $s_ToolTip_Work
    Else
        $s_ToolTip_Final = $s_ToolTip_Work
    EndIf
    StringStripWS($s_ToolTip_Final, 7)
    ToolTip($s_ToolTip_Final)
EndFunc   ;==>_ToolTip_Wrap_Long_String
Edited by KaFu
Link to comment
Share on other sites

It works well with multiple lines !

$_message = 'I have a lot of information ' & @CRLF & _
            'I want to display in a tooltip.' & @CRLF & _
            'I requires several lines.' & @CRLF & _
            'I do not want to have to put all of it in one line, because its long.' & @CRLF & _
            'If I split the command along multiple lines then its not recognized.' & @CRLF & _
            'How can this be done?' 

Tooltip ( $_message )
Sleep ( 5000 )

Show us how you use tooltip...

I just put the string all in one line. I notice that you are using _ to split it into multiple lines. That solves the problem, thanks.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...