Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » One question about Tips.
One question about Tips. [message #459384] Mon, 08 August 2005 15:25 Go to next message
Eclipse UserFriend
Originally posted by: qingxing20052.gmail.com

Dear all:

I have one quesiton:

If I want to keep the tool tip showing as long as the cursor is in the
component, can I do it in SWT?

In Swing, it is easy to do it:
Set ToolTipManager the Max number value.

But SWT doesn't support such method.

How to solve this problem?

I am looking forward to hearing from you.

Thx for any suggestion and help!

Have a nice day,

B.W
Re: One question about Tips. [message #459387 is a reply to message #459384] Mon, 08 August 2005 16:25 Go to previous messageGo to next message
Max Rotvel is currently offline Max RotvelFriend
Messages: 21
Registered: July 2009
Junior Member
On Mon, 08 Aug 2005 17:25:36 +0200, eclipse.newcomer
<qingxing20052@gmail.com> wrote:

> If I want to keep the tool tip showing as long as the cursor is in the
> component, can I do it in SWT?

You can't, probably because the operating system is drawing the tooltips.

> How to solve this problem?

You need to draw your own tooltip. Have a look at the sourcecode for
org.eclipse.jdt.internal.ui.text.java.hover.SourceViewerInfo rmationControl.java

I wrote one that is draggable and disappears when it looses focus. Here's
the code that draws my tooltip shell:

private void show(final Control control, String txt)
{
final Shell shell = new Shell(control.getShell(), SWT.NO_TRIM);
final Display display = shell.getDisplay();

FillLayout layout = new FillLayout();
layout.marginWidth = layout.marginHeight = 1;
shell.setLayout(layout);
shell.setBackground(display.getSystemColor(SWT.COLOR_BLACK)) ;

Composite compo = new Composite(shell, SWT.NONE);
compo.setBackground(display.getSystemColor(SWT.COLOR_INFO_BA CKGROUND));
FillLayout layout2 = new FillLayout();
layout2.marginWidth = layout2.marginHeight = 2;
compo.setLayout(layout2);

Label label = new Label(compo, SWT.NONE);
label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FO REGROUND));
label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BA CKGROUND));
label.setText(txt);

--
Max - rotvel AT bolignet-aarhus DOT dk
Re: One question about Tips. [message #459391 is a reply to message #459387] Mon, 08 August 2005 17:25 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
another snippet that demonstrates a fake tooltip:
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

"Max Rotvel" <this.address@is.invalid> wrote in message
news:op.su66j2v8nl651a@trixie.katlan...
> On Mon, 08 Aug 2005 17:25:36 +0200, eclipse.newcomer
> <qingxing20052@gmail.com> wrote:
>
> > If I want to keep the tool tip showing as long as the cursor is in the
> > component, can I do it in SWT?
>
> You can't, probably because the operating system is drawing the tooltips.
>
> > How to solve this problem?
>
> You need to draw your own tooltip. Have a look at the sourcecode for
>
org.eclipse.jdt.internal.ui.text.java.hover.SourceViewerInfo rmationControl.j
ava
>
> I wrote one that is draggable and disappears when it looses focus. Here's
> the code that draws my tooltip shell:
>
> private void show(final Control control, String txt)
> {
> final Shell shell = new Shell(control.getShell(), SWT.NO_TRIM);
> final Display display = shell.getDisplay();
>
> FillLayout layout = new FillLayout();
> layout.marginWidth = layout.marginHeight = 1;
> shell.setLayout(layout);
> shell.setBackground(display.getSystemColor(SWT.COLOR_BLACK)) ;
>
> Composite compo = new Composite(shell, SWT.NONE);
> compo.setBackground(display.getSystemColor(SWT.COLOR_INFO_BA CKGROUND));
> FillLayout layout2 = new FillLayout();
> layout2.marginWidth = layout2.marginHeight = 2;
> compo.setLayout(layout2);
>
> Label label = new Label(compo, SWT.NONE);
> label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FO REGROUND));
> label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BA CKGROUND));
> label.setText(txt);
>
> --
> Max - rotvel AT bolignet-aarhus DOT dk
Previous Topic:[ANN] Novocode Application Framework 0.2 released
Next Topic:CTabFolder
Goto Forum:
  


Current Time: Mon Sep 23 23:04:58 GMT 2024

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

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

Back to the top