Mouse Motion Events

20 views
Skip to first unread message

Matthew Presley

unread,
Nov 12, 2019, 1:42:15 PM11/12/19
to CheerpJ Developers
I converted a dynamic time series graph application that uses an off-screen buffer for blit-scrolling of the data. I'm surprised (and pleased) that conversion was easy and worked so well. Good job on the CheerpJ!!

That aside, one of the features that does not seem to work is the processing of mouse motion events and mouse drag events. Are these features supposed to work in the generated JavaScript version of my program, or does CheerpJ not yet support mouse motion events?

Thanks!


Alessandro Pignotti

unread,
Nov 12, 2019, 2:28:27 PM11/12/19
to Matthew Presley, CheerpJ Developers
Dear Matthew,

Java mouse events should be fully supported, what version of CheerpJ are you using? I recommend to try out version 2.0RC2, since we have fixed a few corner cases in mouse handling since the 1.4 release.

To try out 2.0RC2 use one of these builds:


If 2.0RC2 does not help, can you isolate a test case? In that way we can then check against native Java to understand how the behavior is incorrect.

Regards,
Alessandro

--
You received this message because you are subscribed to the Google Groups "CheerpJ Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cheerpj-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cheerpj-developers/b0086a80-a49e-4e3f-b252-e8ef3053085b%40googlegroups.com.


--

Leaning Technologies Limited

Alessandro Pignotti
CTO
aless...@leaningtech.com

Leaning Technologies Limited 
www.leaningtech.com

Twitter  Facebook  LinkedIn 

Matthew Presley

unread,
Nov 18, 2019, 3:45:51 PM11/18/19
to CheerpJ Developers
Ends up that it's not a MouseMotion event issue but instead an issue with a component calling getMousePosition(). The following code creates a Frame with a Panel that will track the mouse position with a red circle, positioned from the MouseEvent position field) and a green box positioned from the JPanel getting the mouse coords via getMousePosition(). In this example, it works fine when run as a Java app, but there is no green box when run as JScript produced by CheerpJ. That is, getMousePosition always returns null.

While we're at it, the automatic clearing of the draw area provided by the JComponent superclass doesn't seem to be invoked by the JScript version. That is, the component draw area is not cleared each draw, unlike in the Java version.

This is all run using CheepJ 1.4. I haven't tried the 2.0RC yet.



public class App extends JPanel {


private Point movePoint;

public App() { 

setBackground(Color.black);

addMouseMotionListener(new MouseAdapter() {


@Override

public void mouseMoved(MouseEvent e) {

movePoint = e.getPoint();

repaint();

}

});

}

@Override public void paintComponent(Graphics g) {

super.paintComponents(g);

g.setColor(Color.red);

if (movePoint != null) g.fillOval(movePoint.x, movePoint.y, 10, 10);

Point p = getMousePosition();

g.setColor(Color.green);

if (p != null) g.drawRect(p.x, p.y, 10, 10);

}

public static void main(String[] args) throws IOException {

App app = new App();

JFrame frame = new JFrame();

frame.add("Center", app);

frame.setSize(500, 200);

frame.setVisible(true);

Matthew Presley

unread,
Nov 18, 2019, 3:45:56 PM11/18/19
to CheerpJ Developers
Ok. Same issue with CheerpJ 2.0RC


On Tuesday, November 12, 2019 at 10:42:15 AM UTC-8, Matthew Presley wrote:

Yuri Iozzelli

unread,
Nov 20, 2019, 5:03:25 AM11/20/19
to Matthew Presley, CheerpJ Developers
Hi Matthew,

Thank you for reporting this issue and producing a test case.
We are investigating the problem and we will let you know as soon as we fix it.

Regards,
Yuri

--
You received this message because you are subscribed to the Google Groups "CheerpJ Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cheerpj-develop...@googlegroups.com.

Yuri Iozzelli

unread,
Nov 20, 2019, 12:28:33 PM11/20/19
to Matthew Presley, CheerpJ Developers
Hi Matthew,

Thanks to your test case I fixed the problem with the getMousePosition() function.

For the clearing of the draw area instead, I see the same behavior as CheerpJ in Windows and Linux.
Only on Mac I see the black background and the clearing of the area (see attached image. In order: Windows, Linux, Mac, CheerpJ).

test.png

Since Mac seems to be the odd one here, we are not going to change CheerpJ's behavior. You can maybe explicitly clear the background in your class.

Regards,

Yuri

Alessandro Pignotti

unread,
Nov 21, 2019, 4:12:03 AM11/21/19
to Matthew Presley, CheerpJ Developers
Dear Matthew,

the problem should be fixed with the following runtime: https://cjrtnc.leaningtech.com/20191121/loader.js

To test this you will need to use the 2.0RC2 AOT compiler together with the above runtime loader. This fix will be included in the upcoming 2.0 final release.

Regards,
Alessandro

--
You received this message because you are subscribed to the Google Groups "CheerpJ Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cheerpj-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cheerpj-developers/caf38331-a0a2-4994-b5f8-e0f7ef463836%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages