Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Tooltip on specific entry in TableItem
Tooltip on specific entry in TableItem [message #449022] Mon, 17 January 2005 21:53 Go to next message
Eclipse UserFriend
Originally posted by: lindseygeorge.hotmail.com

Using the example at
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,
I was able to get Tooltips for my table. However, it only shows the text
for the first column entry. How can I get the tooltip to show the text
for each column entry in the TableItem?

How can I get the tooltip to work for TableTreeItems?

Thanks,
Lindsey.
Re: Tooltip on specific entry in TableItem [message #449555 is a reply to message #449022] Wed, 26 January 2005 14:04 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Lindsey,

You need to compute the column that the hover is occurring over. To make
snippet125 do this change the hover listener to what's shown below. You may
need to modify its first line in your use context since it assumes that x=10
will fall within column 0's bounds (if your columns are resizable or your
table scrollable then a little more work is needed here). The changes below
are a good starting point though.

Regarding TableTree, if you're living in the 3.1-stream eclipse world then
you should make use of Tree since it now has TreeColumn capabilities (for
the last ~3 weeks) and is intended to be a native replacement for TableTree.
If you cannot make this change then showing tooltips on a TableTree requires
that you work with its underlying Table, which makes the task essentially
the same as your original question. You can get at the Table with
TableTree.getTable().

case SWT.MouseHover: {
TableItem item = table.getItem (new Point (10, event.y));
if (item != null) {
int columnIndex = -1;
int columnCount = table.getColumnCount();
if (columnCount > 0) {
for (int i = 0; i < columnCount; i++) {
if (item.getBounds(i).contains(event.x, event.y)) {
columnIndex = i;
break;
}
}
if (columnIndex == -1) return; /* hover is too far right */
} else {
columnIndex = 0;
}
if (tip != null && !tip.isDisposed ()) tip.dispose ();
tip = new Shell (shell, SWT.ON_TOP);
tip.setLayout (new FillLayout ());
label = new Label (tip, SWT.NONE);
label.setForeground (display.getSystemColor
(SWT.COLOR_INFO_FOREGROUND));
label.setBackground (display.getSystemColor
(SWT.COLOR_INFO_BACKGROUND));
label.setData ("_TABLEITEM", item);
label.setText ("tooltip "+item.getText (columnIndex));
label.addListener (SWT.MouseExit, labelListener);
label.addListener (SWT.MouseDown, labelListener);
Point size = tip.computeSize (SWT.DEFAULT, SWT.DEFAULT);
Rectangle rect = item.getBounds (columnIndex);
Point pt = table.toDisplay (rect.x, rect.y);
tip.setBounds (pt.x, pt.y, size.x, size.y);
tip.setVisible (true);
}
}

Grant

"Lindsey George" <lindseygeorge@hotmail.com> wrote in message
news:cshcbd$bad$1@www.eclipse.org...
> Using the example at
>
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,
> I was able to get Tooltips for my table. However, it only shows the text
> for the first column entry. How can I get the tooltip to show the text
> for each column entry in the TableItem?
>
> How can I get the tooltip to work for TableTreeItems?
>
> Thanks,
> Lindsey.
Previous Topic:Simple Data Binding
Next Topic:I need to execute some code when workbench exists
Goto Forum:
  


Current Time: Fri Apr 19 22:02:52 GMT 2024

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

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

Back to the top