Jump to content
Sign in to follow this  
Phenom

Displaying lots of information in a tooltip

Recommended Posts

Phenom

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?

Share this post


Link to post
Share on other sites
KaFu

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

Share this post


Link to post
Share on other sites
Phenom

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.

Share this post


Link to post
Share on other sites
wakillon

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

Share this post


Link to post
Share on other sites
KaFu

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

Share this post


Link to post
Share on other sites
Phenom

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.

Share this post


Link to post
Share on other sites
wakillon

@KaFu

Looks good !

I thought he was talking about the number of lines and not their lengths...Posted Image


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

Share this post


Link to post
Share on other sites
wakillon

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.

I use _ just for display the script more easily, not for split text !


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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.