Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] SWT shell and events

Here it is again since there was some formatting in the other code which may not display well:
 
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) { 
   }
});

On Sat, Mar 13, 2010 at 9:43 AM, Kurt Sultana <kurtanatlus@xxxxxxxxx> wrote:
Hi, yes your are right. The problem isn't illustrated well in that code then I realized. My problem is this (I'm developing my own custom tooltip for an Eclipse plug-in):
 
I'm attaching a listener to a 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) {

}

});

How can I go about it?
 
Thanks and regards,
Regards
Krt_Malta


 
On Sat, Mar 13, 2010 at 3:15 AM, zhong nanhai <higerinbeijing@xxxxxxxxx> wrote:
yes, we cann't see this schrollbar in your snippet code.

On 3/13/10, Kurt Sultana <kurtanatlus@xxxxxxxxx> wrote:
> Hi!
>
> I'm developing an Eclipse plug-in and I have a problem which is reproduced
> in this small SWT application:
>
> public static void main(String[] args) {
>     Display display = new Display();
>     Shell shell = new Shell(display);
>     Text text = new Text(shell, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY |
> SWT.V_SCROLL);
>     text.setText("Hello");
>     shell.setLayout(new FillLayout());
>     shell.addMouseTrackListener(new MouseTrackListener() {
>
>       public void mouseEnter(MouseEvent arg0) {
>         System.out.println("mouseEnter");
>
>       }
>
>       public void mouseExit(MouseEvent arg0) {
>         System.out.println("mouseExit");
>
>       }
>
>       public void mouseHover(MouseEvent arg0) {
>         System.out.println("mouseHover");
>
>       }
>     });
>     // Display the window
>     shell.open();
>     while (!shell.isDisposed()) {
>       if (!display.readAndDispatch()) {
>         display.sleep();
>       }
>     }
>     display.dispose();
>   }
>
> As you can see I'm creating a shell and putting a Textbox inside it and
> putting it all across the shell. Then I attach a MouseTrackListener to the
> shell. The events don't fire (as in when I hover in the shell "mouseHover"
> is not printed etc). When I remove the Textbox the events fire. Can anyone
> tell me where the problem lies please? I don't want to attach a listener to
> the textbox but to the shell because if I attach it to the textbox, then the
> shell would dispose when I touch the scrollbar.
>
> Thanks and regards,
> Krt_Malta
>
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top