Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Controls on ScrolledComposite 'guzzles' events
Controls on ScrolledComposite 'guzzles' events [message #454924] Mon, 02 May 2005 19:35 Go to next message
Adam Pordzik is currently offline Adam PordzikFriend
Messages: 19
Registered: July 2009
Junior Member
Hello,

I've putted some Controls (Labels/Buttons) inside a ScrolledComposite/
Composite-pair. As long as the mouse cursor is e.g. directly over the
scroll-bar everything is fine, but when I roll the MouseWheel and the
Cursor is positioned above a control, scrolling stops. :-/

A

--
Re: Controls on ScrolledComposite 'guzzles' events [message #454927 is a reply to message #454924] Tue, 03 May 2005 00:14 Go to previous messageGo to next message
Adam Pordzik is currently offline Adam PordzikFriend
Messages: 19
Registered: July 2009
Junior Member
> I've putted some Controls (Labels/Buttons) inside a ScrolledComposite/
> Composite-pair. As long as the mouse cursor is e.g. directly over the
> scroll-bar everything is fine, but when I roll the MouseWheel and the
> Cursor is positioned above a control, scrolling stops. :-/

Hello,

I could narrow the effect down to preceding Controls within a Layout: If
you leave "Button malicious1" in my following example untouched,
mentioned effect will occour. If you delete line containing "Button
malicious1" everything will work correctly as expected (see Snippet5
from dev.eclipse.org).

It would be nice, if someone can confirm this bug. (At least I consider
this as a bug, but hopefully I just did something wrong)

----

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.custom.*;

public class ModifiedSnippet5 {

public static void main (String [] args)
{
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());

Button malicious1 = new Button (shell, SWT.PUSH);

ScrolledComposite cOuter = new ScrolledComposite (
shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);

Composite cInner = new Composite(cOuter, SWT.BORDER);
cInner.setLayout(new GridLayout());

Button b1 = new Button (cInner, SWT.PUSH);

b1.setText("wheel freezing button");
b1.setBounds (10, 10, 40, 40);

cInner.setSize (400,400);

cOuter.setContent(cInner);

Button malicious2 = new Button (shell, SWT.PUSH);

shell.setSize(600, 300);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

}

A

--
Re: Controls on ScrolledComposite 'guzzles' events [message #454928 is a reply to message #454927] Tue, 03 May 2005 00:28 Go to previous messageGo to next message
Adam Pordzik is currently offline Adam PordzikFriend
Messages: 19
Registered: July 2009
Junior Member
Adam Pordzik schrieb:
>> I've putted some Controls (Labels/Buttons) inside a ScrolledComposite/
>> Composite-pair. As long as the mouse cursor is e.g. directly over the
>> scroll-bar everything is fine, but when I roll the MouseWheel and the
>> Cursor is positioned above a control, scrolling stops. :-/
>
> Hello,
>
> I could narrow the effect down to preceding Controls within a Layout: If
> you leave "Button malicious1" in my following example untouched,
> mentioned effect will occour. If you delete line containing "Button
> malicious1" everything will work correctly as expected (see Snippet5
> from dev.eclipse.org).
>
> It would be nice, if someone can confirm this bug. (At least I consider
> this as a bug, but hopefully I just did something wrong)
>

Or even easier to reproduce within Snippet166 by placing:

"final Button btn = new Button (shell, SWT.PUSH);"

between the lines:

"shell.setLayout(new FillLayout()); // place"

and

"final ScrolledComposite scrollComposite = new ScrolledComposite (
shell, SWT.V_SCROLL | SWT.BORDER);"


A

--
Re: Controls on ScrolledComposite 'guzzles' events [message #454934 is a reply to message #454928] Tue, 03 May 2005 05:42 Go to previous messageGo to next message
Emil Crumhorn is currently offline Emil CrumhornFriend
Messages: 169
Registered: July 2009
Senior Member
I tested your code and after clicking the "freeze" button, scrolling still
works fine for me. But..

You might want to take a look at the ScrollWheel events added in 3.1M4+ that
allow you to listen to the scrollwheel. Some controls on a scrollable canvas
will not scroll the canvas, (some for good reason, such as textareas with
their own scrollbars). But then you at least have the option to scroll your
canvas when ScrollWheel events happen on controls that would normaly not
transfer scroll events to the scrollbars of the canvas.

Hope that helps.

Emil

"Adam Pordzik" <adresseverbummelt@gmx.de> wrote in message
news:d56gsh$9o4$1@news.eclipse.org...
> Adam Pordzik schrieb:
>>> I've putted some Controls (Labels/Buttons) inside a ScrolledComposite/
>>> Composite-pair. As long as the mouse cursor is e.g. directly over the
>>> scroll-bar everything is fine, but when I roll the MouseWheel and the
>>> Cursor is positioned above a control, scrolling stops. :-/
>>
>> Hello,
>>
>> I could narrow the effect down to preceding Controls within a Layout: If
>> you leave "Button malicious1" in my following example untouched,
>> mentioned effect will occour. If you delete line containing "Button
>> malicious1" everything will work correctly as expected (see Snippet5 from
>> dev.eclipse.org).
>>
>> It would be nice, if someone can confirm this bug. (At least I consider
>> this as a bug, but hopefully I just did something wrong)
>>
>
> Or even easier to reproduce within Snippet166 by placing:
>
> "final Button btn = new Button (shell, SWT.PUSH);"
>
> between the lines:
>
> "shell.setLayout(new FillLayout()); // place"
>
> and
>
> "final ScrolledComposite scrollComposite = new ScrolledComposite (
> shell, SWT.V_SCROLL | SWT.BORDER);"
>
>
> A
>
> --
Re: Controls on ScrolledComposite 'guzzles' events [message #454938 is a reply to message #454934] Tue, 03 May 2005 11:05 Go to previous messageGo to next message
Adam Pordzik is currently offline Adam PordzikFriend
Messages: 19
Registered: July 2009
Junior Member
Emil Crumhorn schrieb:
> I tested your code and after clicking the "freeze" button, scrolling still
> works fine for me. But..

Hmm. Due to your posting I've first removed every obsolete swt.jat/dll,
but that doesn't help. What exactly did you have done? It its't needed
to click on the Button in my example, a simple Label works also (better:
doesn't work) when the cursor comes over this control.

Or is my approach to place a composite for collecting Controls inside
another composite bad?

> You might want to take a look at the ScrollWheel events added in 3.1M4+ that
> allow you to listen to the scrollwheel. Some controls on a scrollable canvas
> will not scroll the canvas, (some for good reason, such as textareas with
> their own scrollbars).

Yes. for sure! But i don't want wheeling stopping, when cursor gets over
a drop-down box or even a label. :(

Is there another way? I try to sketch the layout I want to arrange:

+-----------------------------------------------+
| Label | Text | Button |
+-----------------------------------------------+
| |^|
| | |
| scrollable area with misc. control in it. | |
| | |
| |v|
+-----------------------------------------------+
| | Button |
+-----------------------------------------------+

So, these controls were arranged within a GridLayout, the inner area is
the named ScrolledComposite, within a 'normal', laid-out composite with
Labels, Checkboxes, Buttons etc. (And again, if I didn't verbalized it
correctly) As long as my mousecursor stays over the scrollbar, the
composites 'backgroud', everythings works well, but when the cursor
comes over a Label e.g. due to wheeling, scrolling stops.


works:
+----------------------------------+
| |^|
| Label Label | |
| Button Text |\ | |
| | \ |v|
+----------------------------------+


doesn't work:
+----------------------------------+
| |^|
| Label Label | |
| Button T|\t | |
| | \ |v|
+----------------------------------+


where

"|\ "
"| \"

is my mousecursor.

Would it help, if I post longer, "real-world" code?

A

--
Re: Controls on ScrolledComposite 'guzzles' events [message #454941 is a reply to message #454938] Tue, 03 May 2005 12:36 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
There may be different ways you can configure your mouse wheel in the
Windows Control Panel for Mouse. This may account for some differences you
are seeing (also, different windowing systems may by default respond
differently).

For me, the mouse wheel events go to the widget with focus (not the widget
my cursor is over). If the widget with focus does not make use of the mouse
wheel events, the events are propogated up the parent heirarchy until a
widget does make use of them.

The problem with Labels is that they do not take focus. As a result,
another widget such as a button which does take focus will be getting the
mouse wheel events and the events will be going to the parent hierarchy of
the button rather than the label.

One workaround is to use Text with the style READ_ONLY instead of a Label.
The Text widget can take focus.

"Adam Pordzik" <adresseverbummelt@gmx.de> wrote in message
news:d57m7l$hmd$1@news.eclipse.org...
> Emil Crumhorn schrieb:
>> I tested your code and after clicking the "freeze" button, scrolling
>> still works fine for me. But..
>
> Hmm. Due to your posting I've first removed every obsolete swt.jat/dll,
> but that doesn't help. What exactly did you have done? It its't needed to
> click on the Button in my example, a simple Label works also (better:
> doesn't work) when the cursor comes over this control.
>
> Or is my approach to place a composite for collecting Controls inside
> another composite bad?
>
>> You might want to take a look at the ScrollWheel events added in 3.1M4+
>> that allow you to listen to the scrollwheel. Some controls on a
>> scrollable canvas will not scroll the canvas, (some for good reason, such
>> as textareas with their own scrollbars).
>
> Yes. for sure! But i don't want wheeling stopping, when cursor gets over a
> drop-down box or even a label. :(
>
> Is there another way? I try to sketch the layout I want to arrange:
>
> +-----------------------------------------------+
> | Label | Text | Button |
> +-----------------------------------------------+
> | |^|
> | | |
> | scrollable area with misc. control in it. | |
> | | |
> | |v|
> +-----------------------------------------------+
> | | Button |
> +-----------------------------------------------+
>
> So, these controls were arranged within a GridLayout, the inner area is
> the named ScrolledComposite, within a 'normal', laid-out composite with
> Labels, Checkboxes, Buttons etc. (And again, if I didn't verbalized it
> correctly) As long as my mousecursor stays over the scrollbar, the
> composites 'backgroud', everythings works well, but when the cursor comes
> over a Label e.g. due to wheeling, scrolling stops.
>
>
> works:
> +----------------------------------+
> | |^|
> | Label Label | |
> | Button Text |\ | |
> | | \ |v|
> +----------------------------------+
>
>
> doesn't work:
> +----------------------------------+
> | |^|
> | Label Label | |
> | Button T|\t | |
> | | \ |v|
> +----------------------------------+
>
>
> where
>
> "|\ "
> "| \"
>
> is my mousecursor.
>
> Would it help, if I post longer, "real-world" code?
>
> A
>
> --
Re: Controls on ScrolledComposite 'guzzles' events [message #454973 is a reply to message #454941] Tue, 03 May 2005 18:28 Go to previous messageGo to next message
Adam Pordzik is currently offline Adam PordzikFriend
Messages: 19
Registered: July 2009
Junior Member
Veronika Irvine schrieb:

> For me, the mouse wheel events go to the widget with focus (not the widget
> my cursor is over). If the widget with focus does not make use of the mouse
> wheel events, the events are propogated up the parent heirarchy until a
> widget does make use of them.

I've added a display.addFilter (SWT.MouseWheel, ...) to see what will
happen and remarked that some rotations doesn't produced any event,
although the inner Composite was beeing scrolled.

> The problem with Labels is that they do not take focus. As a result,
> another widget such as a button which does take focus will be getting the
> mouse wheel events and the events will be going to the parent hierarchy of
> the button rather than the label.

What I don't understand, is why does wheel-scrolling still works with
the "malicious" Control focussed, as long my mouse is over Composite or
scrollableComposite, although they do not have focus?

> One workaround is to use Text with the style READ_ONLY instead of a Label.
> The Text widget can take focus.

....and keeps it because Text is also scrollable. How do I can send an
Event to the parent manually, or tell Text to ignore the event? I'd
assumed "setCapture(false)" for this job, but...

I am still nearly as confused as at the beginning. :-/

For now I've worked aroud with an display.addFilter, and look whether
mouse is over my scrollableComposite:

display.addFilter(SWT.MouseMove, new Listener () {
public void handleEvent(Event e) {
Control p = (Control) e.widget;
while (p != null) {
if (p == scrollableComposite) {
p.setFocus();
break;
}
p = p.getParent();
}
}
});

This works satisfying, but I'm not sure whether this is a good approach.

A

P.S.

Veronika, as I see, you are the owner of this what I've commited as a
bug. If you like, I can send you a more illustating example.

--
Re: Controls on ScrolledComposite 'guzzles' events [message #454980 is a reply to message #454973] Tue, 03 May 2005 21:02 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
> Veronika, as I see, you are the owner of this what I've commited as a bug.
> If you like, I can send you a more illustating example.

If you have another example, please add it to bug 93472. We should probably
move this discussion to the bug report.
Previous Topic:JFace source available?
Next Topic:Broswer control on an Offscreen?
Goto Forum:
  


Current Time: Thu Apr 25 12:18:42 GMT 2024

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

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

Back to the top