|
Re: mouseExit triggers on scrollbar?? [message #520838 is a reply to message #520533] |
Mon, 15 March 2010 10:33  |
Eclipse User |
|
|
|
Hi,
The only way I can think of to do what you want is with an approach like
below. It's not pretty but it seems to work.
static Runnable runnable = null;
static int INTERVAL = 99;
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display, SWT.TOOL);
shell.setLayout(new GridLayout());
final Text text = new Text(shell, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP |
SWT.V_SCROLL);
text.setLayoutData(new GridData(200,200));
text.addListener(SWT.MouseExit, new Listener() {
public void handleEvent(Event event) {
if (display.getCursorControl() != text) {
System.out.println("exited via edge without scrollbar, so
hide it now");
} else {
runnable = new Runnable() {
public void run() {
if (text.isDisposed()) return;
if (display.getCursorControl() != text) {
System.out.println("exited scrollbar, so hide it
now");
} else {
display.timerExec(INTERVAL, this);
}
}
};
display.timerExec(INTERVAL, runnable);
}
}
});
text.addListener(SWT.MouseEnter, new Listener() {
public void handleEvent(Event event) {
if (runnable != null) {
display.timerExec(-1, runnable);
}
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
HTH,
Grant
<kurtanatlus@gmail.com> wrote in message
news:hne0h3$r9s$1@build.eclipse.org...
> Hi!
>
> I made my own custom tooltip in SWT for an Eclipse-plugin. It works fine
overall however I bumped into an issue:
>
> I'm attaching a listener to the Text (which has a V_Scroll with it) which
is inside a shell. The problem is that when I move the mouse over the
vertical scrollbar the shell is disposed. I don't want that.
>
> This is the code:
>
> popup = new Shell(PlatformUI.getWorkbench().getDisplay(), SWT.TOOL );
> Text text = new Text(popup, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP |
SWT.V_SCROLL);
>
> text.addMouseTrackListener(new MouseTrackListener() {
> public void mouseHover(MouseEvent e) {
> }
> public void mouseExit(MouseEvent e) {
> popup.dispose();
> }
> public void mouseEnter(MouseEvent e) {
> }
> });
>
> How can I resolve this? I've been trying to find a way for a long time now
but no solution :(
>
> Thanks and regards,
> Krt_Malta
|
|
|
Powered by
FUDForum. Page generated in 0.03501 seconds