Example of using mouse events in study?

Shtick Hustler

Well-known member
Joined
Oct 15, 2020
Posts
106
Likes
46
Searched the MW example studies and saw no examples of use of the following methods.

Does anyone have an example to share?

Code:
onDoubleClick()

onClick()

onWheelMoved()
 

Spin

Well-known member
Joined
May 22, 2019
Posts
480
Likes
192
I checked: nothing in my archive / the older SDK.jar's.
I'm quite surprised actually :unsure:
 

Shtick Hustler

Well-known member
Joined
Oct 15, 2020
Posts
106
Likes
46
I
There is a tiny bit about those methods in the SDK manual:

https://www.motivewave.com/sdk/MotiveWave_SDK_Programming_Guide.pdf
(page 31 -32)

I saw the addition of these methods mentioned, but missed these specifics...thanks.

For a 1st test, I added onclick, and just had it print the Point and Int:

Java:
@Override
public boolean onClick(Point pnt, int modKey) {
    System.out.println("\n ---->onClick()");
    System.out.println(tt + " pnt = " + pnt);
    System.out.println(tt + " modKey = " + modKey);

    return super.onClick(pnt, modKey);
}

Then got this output when I clicked:

Code:
---->onClick()
         pnt = java.awt.Point[x=586,y=172]
         modKey = 0

Next step is to figure out how to translate from these Point() values into MW's time/price values, so I can tell what's been clicked on in code.
 
Last edited:

Shtick Hustler

Well-known member
Joined
Oct 15, 2020
Posts
106
Likes
46
Found it:

Code:
// Translates a 'real' date and value into a point on the graph.
Point2D translate(long time, double value)

Here @ DrawContext

On further research, I discovered using DrawContext is a bit of an advanced procedure. You can't just use an override function to grab a DrawContext reference. It requires creating a static class extending figures, or custom class constructors.

Here's an example from the MoonPhases study:

Java:
  private static class MoonPhase extends Figure
  {
    MoonPhase(long time, Phase p, boolean show24)
    {
      this.time = time;
      phase = p;
      SimpleDateFormat fmt = show24 ? fmt24 : fmt12;
      topLbl = new Text(fmt.format(time), TIMF_FONT, new Insets(1, 3, 1, 1), false);
      bottomLbl = new Text(fmt.format(time), TIMF_FONT, new Insets(1, 3, 1, 1), false);
    }

I don't have time to explore it at the moment; just wanted to give a heads-up to anyone who does.
 
Top