Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » To add tooltip for grid items
To add tooltip for grid items [message #17146] Mon, 27 November 2006 16:07 Go to next message
Eclipse UserFriend
Originally posted by: krishna.24jan.gmail.com

Hi,

Can any one suggest any possible solution to add tool tip for grid items.

Currently nebula supports tooltip for grid.I want to add tooltip for grid
items which will display its rown and column .

Can any one throw some light in this issue.


Thanks in advance
krishna
Re: To add tooltip for grid items [message #17255 is a reply to message #17146] Mon, 27 November 2006 16:26 Go to previous messageGo to next message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
If you want tooltips that are specific to each cell you can do something
like:

grid.addListener(SWT.MouseMove, new Listener()
{
public void handleEvent(Event e)
{
Point p = new Point(e.x,e.y);
GridColumn col = grid.getColumn(p);
GridItem item = grid.getItem(p);
//determine if the col and item have changed from
//previous saved values (i.e. user just moving in new cell?)
grid.setToolTipText("MyToolTipText");
}
});

Regards,
-Chris

krishna wrote:
> Hi,
>
> Can any one suggest any possible solution to add tool tip for grid items.
>
> Currently nebula supports tooltip for grid.I want to add tooltip for
> grid items which will display its rown and column .
>
> Can any one throw some light in this issue.
>
>
> Thanks in advance
> krishna
>
Re: To add tooltip for grid items [message #17861 is a reply to message #17146] Mon, 27 November 2006 16:34 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi krishna,

That's better and here's the answer.

Checkout the following classes from JFace-Head:
-http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org .eclipse.jface/src/org/eclipse/jface/window/ToolTip.java
-http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org .eclipse.jface/src/org/eclipse/jface/window/DefaultToolTip.j ava
Although they are in JFace 3.3 you can use them without problems in 3.2.
The checkout the http://tom-eclipse-dev.blogspot.com/ to see how they
are used.

If you are using DefaultToolTip code looks like this:

---------------------8<---------------------
protected boolean shouldCreateToolTip(Event event) {
Point p = new Point(event.x,event.y);
GridItem gi = grid.getItem(p);

for( int i = 0; gi != null && i < grid.getColumns().length; i++ ) {
if( gi.contains(p) ) {
setText("ToolTip: " + gi.getText(i) );
return true;
}
}

return false;
}
---------------------8<---------------------

I assume in the code above that Grid is working the same as SWT-Table
but Chris can tell you more. I haven't tried to run this code myself it
simply should get you started. Give it a try and report back if it works
for you.

Tom

krishna schrieb:
> Hi,
>
> Can any one suggest any possible solution to add tool tip for grid items.
>
> Currently nebula supports tooltip for grid.I want to add tooltip for
> grid items which will display its rown and column .
>
> Can any one throw some light in this issue.
>
>
> Thanks in advance
> krishna
>
Re: To add tooltip for grid items [message #17869 is a reply to message #17255] Tue, 28 November 2006 05:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: krishna.24jan.gmail.com

Dear Chris,

Thanks a lot for the info.I really appreciate the help.
But in the code u have sent we can get the mouse locations 'p'.
I want to dislay tooltip for the cells displaying its respective rows and
columns
From 'P' i can get columnNo but iam unable to get row no.

Can u help me out in this..

Thanks in advance
krishna
Re: To add tooltip for grid items [message #17896 is a reply to message #17869] Tue, 28 November 2006 08:35 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Wrong please reread the snippet from Chris:
------------------8<-------------------------
GridItem item = grid.getItem(p); // This is the row
------------------8<-------------------------

Tom

krishna schrieb:
> Dear Chris,
>
> Thanks a lot for the info.I really appreciate the help.
> But in the code u have sent we can get the mouse locations 'p'.
> I want to dislay tooltip for the cells displaying its respective rows
> and columns
> From 'P' i can get columnNo but iam unable to get row no.
>
> Can u help me out in this..
>
> Thanks in advance
> krishna
>
Re: To add tooltip for grid items [message #569253 is a reply to message #17146] Mon, 27 November 2006 16:26 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
If you want tooltips that are specific to each cell you can do something
like:

grid.addListener(SWT.MouseMove, new Listener()
{
public void handleEvent(Event e)
{
Point p = new Point(e.x,e.y);
GridColumn col = grid.getColumn(p);
GridItem item = grid.getItem(p);
//determine if the col and item have changed from
//previous saved values (i.e. user just moving in new cell?)
grid.setToolTipText("MyToolTipText");
}
});

Regards,
-Chris

krishna wrote:
> Hi,
>
> Can any one suggest any possible solution to add tool tip for grid items.
>
> Currently nebula supports tooltip for grid.I want to add tooltip for
> grid items which will display its rown and column .
>
> Can any one throw some light in this issue.
>
>
> Thanks in advance
> krishna
>
Re: To add tooltip for grid items [message #569332 is a reply to message #17146] Mon, 27 November 2006 16:34 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi krishna,

That's better and here's the answer.

Checkout the following classes from JFace-Head:
-http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org .eclipse.jface/src/org/eclipse/jface/window/ToolTip.java
-http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org .eclipse.jface/src/org/eclipse/jface/window/DefaultToolTip.j ava
Although they are in JFace 3.3 you can use them without problems in 3.2.
The checkout the http://tom-eclipse-dev.blogspot.com/ to see how they
are used.

If you are using DefaultToolTip code looks like this:

---------------------8<---------------------
protected boolean shouldCreateToolTip(Event event) {
Point p = new Point(event.x,event.y);
GridItem gi = grid.getItem(p);

for( int i = 0; gi != null && i < grid.getColumns().length; i++ ) {
if( gi.contains(p) ) {
setText("ToolTip: " + gi.getText(i) );
return true;
}
}

return false;
}
---------------------8<---------------------

I assume in the code above that Grid is working the same as SWT-Table
but Chris can tell you more. I haven't tried to run this code myself it
simply should get you started. Give it a try and report back if it works
for you.

Tom

krishna schrieb:
> Hi,
>
> Can any one suggest any possible solution to add tool tip for grid items.
>
> Currently nebula supports tooltip for grid.I want to add tooltip for
> grid items which will display its rown and column .
>
> Can any one throw some light in this issue.
>
>
> Thanks in advance
> krishna
>
Re: To add tooltip for grid items [message #569404 is a reply to message #17255] Tue, 28 November 2006 05:02 Go to previous message
krishna is currently offline krishnaFriend
Messages: 48
Registered: July 2009
Member
Dear Chris,

Thanks a lot for the info.I really appreciate the help.
But in the code u have sent we can get the mouse locations 'p'.
I want to dislay tooltip for the cells displaying its respective rows and
columns
From 'P' i can get columnNo but iam unable to get row no.

Can u help me out in this..

Thanks in advance
krishna
Re: To add tooltip for grid items [message #569468 is a reply to message #17869] Tue, 28 November 2006 08:35 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Wrong please reread the snippet from Chris:
------------------8<-------------------------
GridItem item = grid.getItem(p); // This is the row
------------------8<-------------------------

Tom

krishna schrieb:
> Dear Chris,
>
> Thanks a lot for the info.I really appreciate the help.
> But in the code u have sent we can get the mouse locations 'p'.
> I want to dislay tooltip for the cells displaying its respective rows
> and columns
> From 'P' i can get columnNo but iam unable to get row no.
>
> Can u help me out in this..
>
> Thanks in advance
> krishna
>
Previous Topic:Multiple selection of items in nebula grid
Next Topic:Grid - Cell Height
Goto Forum:
  


Current Time: Tue Apr 16 13:16:21 GMT 2024

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

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

Back to the top