Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Multiline tooltips
Multiline tooltips [message #459693] Sun, 14 August 2005 10:57 Go to next message
Omry Yadan is currently offline Omry YadanFriend
Messages: 45
Registered: July 2009
Member
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 12:08 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
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 11:15 Go to previous messageGo to next message
Omry Yadan is currently offline Omry YadanFriend
Messages: 45
Registered: July 2009
Member
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 12:40 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
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 16:17 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
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 13:41 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
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: Fri Apr 16 03:55:58 GMT 2021

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

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

Back to the top