Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Multiline tooltips
Multiline tooltips [message #459693] Sun, 14 August 2005 06:57 Go to next message
Eclipse UserFriend
Hi,
I have a list canvas with several virtual components in it.
I managed to get tooltips for list items by adding mouseHover listener
to the list:


@Override
public void mouseHover(MouseEvent e)
{
IControl item = findUnderMouse();
if (item != null)
{
if (item instanceof ListItem)
{
ListItem li = (ListItem) item;
setToolTipText(li.getToolTipText());
}
}
}


the problem is as follows:
the tooltip string maybe very long (sometimes longer than the screen
width), so I need the tooltop to wrap the string.
how can I do it?
(Tooltips that behave like Eclipse's java doc tooltips will be nice).

Thanks.
Re: Multiline tooltips [message #459694 is a reply to message #459693] Sun, 14 August 2005 08:08 Go to previous messageGo to next message
Eclipse UserFriend
You have to create a fake tooltip. See
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet125.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup

Ben
> Hi,
> I have a list canvas with several virtual components in it.
> I managed to get tooltips for list items by adding mouseHover listener
> to the list:
>
>
> @Override
> public void mouseHover(MouseEvent e)
> {
> IControl item = findUnderMouse();
> if (item != null)
> {
> if (item instanceof ListItem)
> {
> ListItem li = (ListItem) item;
> setToolTipText(li.getToolTipText());
> }
> }
> }
>
>
> the problem is as follows:
> the tooltip string maybe very long (sometimes longer than the screen
> width), so I need the tooltop to wrap the string.
> how can I do it?
> (Tooltips that behave like Eclipse's java doc tooltips will be nice).
>
> Thanks.
Y
Re: Multiline tooltips [message #459695 is a reply to message #459694] Sun, 14 August 2005 07:15 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the quick response.
is there utility code in swt for text wrapping?
or generally, figuring the best size for a label that contains a warpped
string?


Benjamin Pasero wrote:
> You have to create a fake tooltip. See
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet125.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup
>
>
> Ben
>
>> Hi,
>> I have a list canvas with several virtual components in it.
>> I managed to get tooltips for list items by adding mouseHover listener
>> to the list:
>>
>>
>> @Override
>> public void mouseHover(MouseEvent e)
>> {
>> IControl item = findUnderMouse();
>> if (item != null)
>> {
>> if (item instanceof ListItem)
>> {
>> ListItem li = (ListItem) item;
>> setToolTipText(li.getToolTipText());
>> }
>> }
>> }
>>
>>
>> the problem is as follows:
>> the tooltip string maybe very long (sometimes longer than the screen
>> width), so I need the tooltop to wrap the string.
>> how can I do it?
>> (Tooltips that behave like Eclipse's java doc tooltips will be nice).
>>
>> Thanks.
>
> Y
Re: Multiline tooltips [message #459696 is a reply to message #459695] Sun, 14 August 2005 08:40 Go to previous messageGo to next message
Eclipse UserFriend
See SWT.WRAP style hint for Text and StyledText widget.

Ben
> Thanks for the quick response.
> is there utility code in swt for text wrapping?
> or generally, figuring the best size for a label that contains a
> warpped string?
>
>
> Benjamin Pasero wrote:
>> You have to create a fake tooltip. See
>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet125.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup
>>
>>
>> Ben
>>
>>> Hi,
>>> I have a list canvas with several virtual components in it.
>>> I managed to get tooltips for list items by adding mouseHover
>>> listener to the list:
>>>
>>>
>>> @Override
>>> public void mouseHover(MouseEvent e)
>>> {
>>> IControl item = findUnderMouse();
>>> if (item != null)
>>> {
>>> if (item instanceof ListItem)
>>> {
>>> ListItem li = (ListItem) item;
>>> setToolTipText(li.getToolTipText());
>>> }
>>> }
>>> }
>>>
>>>
>>> the problem is as follows:
>>> the tooltip string maybe very long (sometimes longer than the screen
>>> width), so I need the tooltop to wrap the string.
>>> how can I do it?
>>> (Tooltips that behave like Eclipse's java doc tooltips will be nice).
>>>
>>> Thanks.
>>
>> Y
Re: Multiline tooltips [message #459780 is a reply to message #459695] Tue, 16 August 2005 12:17 Go to previous messageGo to next message
Eclipse UserFriend
If you want your Label (created with SWT.WRAP) to be, for example, 300
pixels wide, then you can use Label.computeSize(300, SWT.DEFAULT) to
determine the height that this label will need to be to show its contents.
This will take correct wrapping of its contents at pixel 300 into account.

Grant

"Omry Yadan" <omry_y@inter.net.il> wrote in message
news:ddn8v1$3h1$1@news.eclipse.org...
> Thanks for the quick response.
> is there utility code in swt for text wrapping?
> or generally, figuring the best size for a label that contains a warpped
> string?
>
>
> Benjamin Pasero wrote:
> > You have to create a fake tooltip. See
> >
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet125.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup
> >
> >
> > Ben
> >
> >> Hi,
> >> I have a list canvas with several virtual components in it.
> >> I managed to get tooltips for list items by adding mouseHover listener
> >> to the list:
> >>
> >>
> >> @Override
> >> public void mouseHover(MouseEvent e)
> >> {
> >> IControl item = findUnderMouse();
> >> if (item != null)
> >> {
> >> if (item instanceof ListItem)
> >> {
> >> ListItem li = (ListItem) item;
> >> setToolTipText(li.getToolTipText());
> >> }
> >> }
> >> }
> >>
> >>
> >> the problem is as follows:
> >> the tooltip string maybe very long (sometimes longer than the screen
> >> width), so I need the tooltop to wrap the string.
> >> how can I do it?
> >> (Tooltips that behave like Eclipse's java doc tooltips will be nice).
> >>
> >> Thanks.
> >
> > Y
Re: Multiline tooltips [message #460381 is a reply to message #459693] Wed, 24 August 2005 09:41 Go to previous message
Eclipse UserFriend
If you put a '\n' in your text, it will display on a new line.

"Omry Yadan" <omry_y@inter.net.il> wrote in message
news:ddn7ss$2q0$1@news.eclipse.org...
> Hi,
> I have a list canvas with several virtual components in it.
> I managed to get tooltips for list items by adding mouseHover listener
> to the list:
>
>
> @Override
> public void mouseHover(MouseEvent e)
> {
> IControl item = findUnderMouse();
> if (item != null)
> {
> if (item instanceof ListItem)
> {
> ListItem li = (ListItem) item;
> setToolTipText(li.getToolTipText());
> }
> }
> }
>
>
> the problem is as follows:
> the tooltip string maybe very long (sometimes longer than the screen
> width), so I need the tooltop to wrap the string.
> how can I do it?
> (Tooltips that behave like Eclipse's java doc tooltips will be nice).
>
> Thanks.
Previous Topic:serialize Image
Next Topic:Shell Titlebar menu
Goto Forum:
  


Current Time: Sat Jul 12 21:21:31 EDT 2025

Powered by FUDForum. Page generated in 0.05303 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top