Home » Eclipse Projects » GEF » draw2d: findMouseEventTarget
draw2d: findMouseEventTarget [message #25525] |
Tue, 08 October 2002 09:59  |
Eclipse User |
|
|
|
Good day,
Problem occured when I tried to implement simple editor using draw2d.
The drawing below contains the root figure A, which is parent of the
figure B and figure L (PolyLine, but it does not matter).
+---------------------------+
| A |
| +----------------+ |
| L | <p> B | |
| *---+----*----* | |
| | | |
| +----------------+ |
+---------------------------+
A and B have mouse listeners, while L has not. When I click at the
point <p>, mouse event comes to A, which searches for child,
containing <p>, _then A found L, L has no mouse listener, and A
decides to processes event mouse event itself_. I expected that
figure B should receive this event, but it doesn't.
I think, it's bug (see code below), but if I wrong, it would be
nice to know, how can I avoid this situation.
--- Figure.java ---
IFigure findMouseEventTargetInDescendantsAt(int x, int y){
if(useLocalCoordinates()){
x -= (getBounds().x + getInsets().left);
y -= (getBounds().y + getInsets().top);
}
FigureIterator iter = new FigureIterator(this);
IFigure fig;
while (iter.hasNext()){
fig = iter.nextFigure();
if (fig.isVisible() && fig.isEnabled()){
if (fig.containsPoint(x, y)){
fig = fig.findMouseEventTargetAt(x, y);
// return fig; << bug?
// changed:
if (fig!=null) return fig;
}
}
}
return null;
}
---
/Sergey
|
|
|
Re: draw2d: findMouseEventTarget [message #25764 is a reply to message #25525] |
Tue, 08 October 2002 15:01   |
Eclipse User |
|
|
|
Originally posted by: hudsonr.us.eye-bee-em.com
This is a multi-part message in MIME format.
------=_NextPart_000_002D_01C26EDB.95420420
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Your proposed change in hit-testing seems consistent with Windows. Does =
anyone know if this is how other platforms work? I thought we were =
being like Swing, but maybe not. In the following SWT test, mouse =
events "fall through" the inactive sibling. Open a bugzilla for this.
public static void main(String[] args) {
Display d =3D new Display();
final Shell shell =3D new Shell(d);
shell.setText("Hittest demonstration");
Button b1, b2;
b1 =3D new Button(shell, 0);
b2 =3D new Button(shell, 0);
=20
b1.setBounds(20,20,200,100);
b2.setBounds(30,30,200,100);
b1.setEnabled(false);
=20
shell.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
shell.setBackground(new Color(null, 0,0,0)); //Bad code
}
public void mouseUp(MouseEvent e) {
shell.setBackground(null);
}
});
shell.setSize(300,260);
shell.open();
while (!shell.isDisposed())
while (!d.readAndDispatch())
d.sleep();
}
"Sergey Bushkov" <bush@ispras.ru> wrote in message =
news:anujbj$2s6$1@rogue.oti.com...
> Good day,
>=20
> Problem occured when I tried to implement simple editor using draw2d.
> The drawing below contains the root figure A, which is parent of the
> figure B and figure L (PolyLine, but it does not matter).
>=20
> +---------------------------+
> | A |
> | +----------------+ |
> | L | <p> B | |
> | *---+----*----* | |
> | | | |
> | +----------------+ |
> +---------------------------+
>=20
> A and B have mouse listeners, while L has not. When I click at the
> point <p>, mouse event comes to A, which searches for child,
> containing <p>, _then A found L, L has no mouse listener, and A
> decides to processes event mouse event itself_. I expected that
> figure B should receive this event, but it doesn't.
>=20
> I think, it's bug (see code below), but if I wrong, it would be
> nice to know, how can I avoid this situation.
>=20
> --- Figure.java ---
> IFigure findMouseEventTargetInDescendantsAt(int x, int y){
> if(useLocalCoordinates()){
> x -=3D (getBounds().x + getInsets().left);
> y -=3D (getBounds().y + getInsets().top);
> }
> FigureIterator iter =3D new FigureIterator(this);
> IFigure fig;
> while (iter.hasNext()){
> fig =3D iter.nextFigure();
> if (fig.isVisible() && fig.isEnabled()){
> if (fig.containsPoint(x, y)){
> fig =3D fig.findMouseEventTargetAt(x, y);
> =20
> // return fig; << bug?
> // changed:
> if (fig!=3Dnull) return fig;
> }
> }
> }
> return null;
> }
> ---
>=20
> /Sergey
>=20
------=_NextPart_000_002D_01C26EDB.95420420
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2716.2200" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Your proposed change in hit-testing =
seems=20
consistent with Windows. Does anyone know if this is how other =
platforms=20
work? I thought we were being like Swing, but maybe =
not. In the=20
following SWT test, mouse events "fall through" the inactive =
sibling. Open=20
a bugzilla for this.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2>public static void=20
main(String[] args) {<BR> Display d =3D new =
Display();<BR> final Shell=20
shell =3D new Shell(d);<BR> shell.setText("Hittest=20
demonstration");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> Button b1, b2;<BR> b1 =3D =
new=20
Button(shell, 0);<BR> b2 =3D new Button(shell,=20
0);<BR> <BR> b1.setBounds(20,20,200,100); <BR> b2.setBounds=
(30,30,200,100);<BR> b1.setEnabled(false);<BR> <BR> shell.=
addMouseListener(new=20
MouseAdapter() {<BR> public void mouseDown(MouseEvent e)=20
{<BR> shell.setBackground(new Color(null, 0,0,0)); =
//Bad=20
code<BR> }<BR> public void mouseUp(MouseEvent e)=20
{<BR> shell.setBackground(null); <BR> }<BR>&nb=
sp;});</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial=20
size=3D2> shell.setSize(300,260);<BR> shell.open(); <BR> wh=
ile=20
(!shell.isDisposed())<BR> while=20
(!d.readAndDispatch())<BR> d.sleep(); <BR>}<BR></FONT></D=
IV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>"Sergey Bushkov" <</FONT><A=20
href=3D"mailto:bush@ispras.ru"><FONT face=3DArial=20
size=3D2>bush@ispras.ru</FONT></A><FONT face=3DArial size=3D2>> wrote =
in message=20
</FONT><A href=3D"news:anujbj$2s6$1@rogue.oti.com"><FONT face=3DArial=20
size=3D2>news:anujbj$2s6$1@rogue.oti.com</FONT></A><FONT face=3DArial=20
size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>> Good =
day,<BR>> <BR>>=20
Problem occured when I tried to implement simple editor using =
draw2d.<BR>>=20
The drawing below contains the root figure A, which is parent of =
the<BR>>=20
figure B and figure L (PolyLine, but it does not matter).<BR>> =
<BR><FONT=20
face=3DCourier>> +---------------------------+<BR>>=20
|   ;   ;=
&=
nbsp;=20
A |<BR>> | =
+----------------+ =20
|<BR>> | L | =20
<p> &am p;nbsp; B =
| =20
|<BR>> | *---+----*----* & nbsp;=20
| |<BR>> | =20
|   ;   ;=
=20
| |<BR>> | =20
+----------------+ |<BR>>=20
+---------------------------+<BR>> </FONT><BR>> A and B have =
mouse=20
listeners, while L has not. When I click at the<BR>> point <p>, =
mouse=20
event comes to A, which searches for child,<BR>> containing =
<p>, _then=20
A found L, L has no mouse listener, and A<BR>> decides to processes =
event=20
mouse event itself_. I expected that<BR>> figure B should receive =
this event,=20
but it doesn't.<BR>> <BR>> I think, it's bug (see code below), but =
if I=20
wrong, it would be<BR>> nice to know, how can I avoid this =
situation.<BR>>=20
<BR>> --- Figure.java ---<BR>> IFigure=20
findMouseEventTargetInDescendantsAt(int x, int y){<BR>> =
=20
if(useLocalCoordinates()){<BR>> =
x=20
-=3D (getBounds().x + getInsets().left);<BR>>=20
y -=3D (getBounds().y +=20
getInsets().top);<BR>> }<BR>> =
=20
FigureIterator iter =3D new FigureIterator(this);<BR>> =
=20
IFigure fig;<BR>> while (iter.hasNext()){<BR>>=20
fig =3D =
iter.nextFigure();<BR>>=20
if (fig.isVisible() =
&&=20
fig.isEnabled()){<BR>>=20
if=20
(fig.containsPoint(x, y)){<BR>>=20
&=
nbsp; =20
fig =3D fig.findMouseEventTargetAt(x, y);<BR>>=20
&=
nbsp; =20
<BR>>=20
&=
nbsp; =20
// return fig; << bug?<BR>>=20
&=
nbsp; =20
// changed:<BR>>=20
&=
nbsp; =20
if (fig!=3Dnull) return fig;<BR>>=20
=
}<BR>>=20
}<BR>> =20
}<BR>> return null;<BR>> }<BR>> ---<BR>> =
<BR>>=20
/Sergey<BR>> </FONT></BODY></HTML>
------=_NextPart_000_002D_01C26EDB.95420420--
|
|
| |
Re: draw2d: findMouseEventTarget [message #26065 is a reply to message #25863] |
Wed, 09 October 2002 10:14  |
Eclipse User |
|
|
|
Originally posted by: hudsonr.us.eye-bee-em.com
"Sergey Bushkov" <bush@ispras.ru> wrote in message
news:ao0ti6$gis$1@rogue.oti.com...
> > Your proposed change in hit-testing seems consistent with Windows.
> Does anyone know
> > if this is how other platforms work? I thought we were being like
> Swing, but maybe not.
> > In the following SWT test, mouse events "fall through" the inactive
> sibling.
>
> :) nice example.
> But it does not "fall" through second button at least.. When using
> draw2d, such events
> "fall" down to the root Figure.
I know, my point was that the example shows what you would like to happen,
not what currently happens.
>
> > Open a bugzilla for this.
>
> ok.
>
|
|
|
Goto Forum:
Current Time: Fri Apr 18 20:14:51 EDT 2025
Powered by FUDForum. Page generated in 0.03646 seconds
|