Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » mouseExit triggers on scrollbar??
mouseExit triggers on scrollbar?? [message #520533] Fri, 12 March 2010 18:18 Go to next message
No real name is currently offline No real nameFriend
Messages: 6
Registered: December 2009
Junior Member
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 );
popup.setLayout(new FillLayout());
Text text = new Text(popup, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
text.setBackground(new org.eclipse.swt.graphics.Color(PlatformUI.getWorkbench().getDisplay(), 255, 255, 204));
text.addMouseTrackListener(new MouseTrackListener() { 
   public void mouseHover(MouseEvent e) { 
   }    
   public void mouseExit(MouseEvent e) { 
      popup.dispose();   
   }    
   public void mouseEnter(MouseEvent e) { 
   } 
});
popup.setSize(200, 100);
text.setText("The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog");
popup.open();


How can I resolve this? I've been trying to find a way for a long time now but no solution Sad

Thanks and regards,
Krt_Malta

[Updated on: Sat, 13 March 2010 09:00]

Report message to a moderator

Re: mouseExit triggers on scrollbar?? [message #520838 is a reply to message #520533] Mon, 15 March 2010 14:33 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
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
Previous Topic:TreeItem.setExpanded() issue on Linux
Next Topic:Fwd: Focus and key events with SWT_AWT bridge
Goto Forum:
  


Current Time: Wed Apr 24 15:30:48 GMT 2024

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

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

Back to the top