setUnboundedMouseMovement() problems

Seems like when using setUnboundedMouseMovement() with the latest GIT, all sorts of weird things happen. For instance, it seems that when the mouse cursor (that is hidden) goes to far up, then its like it hits the top (without you seeing it) and its like the values then start jumping around.

Maybe something to do with the new transform stuff… Thanks, I’ll check it out…

Hmm… nope, seems to be working ok here. I was trying it with the sliders in the juce demo, and they seem ok. How could I reproduce the problem?

I suspect that it has something to do with getMouseXYRelative() because I am using this function in my mouseDrag(). It all works with JUCE146.

void MidiKeyEditorViewNotesHolder::meterMouseDrag(MidiKeyEditorMeter *meter, const MouseEvent &e) { int x,y; #if JUCE146 parent->getMouseXYRelative(x,y); #else const Point<int> pt=parent->getMouseXYRelative(); x=pt.getX(); y=pt.getY(); #endif int dx=x-mouseDownX; int dy=y-mouseDownY; zoomInternal(dx,dy); }

Ah yes, looks like getMouseXYRelative() needs tweaking to handle the new multi-touch MouseInputSource stuff.

That’s not a recommended way to get the mouse position anyway, as you need to start thinking in term of possible multi-touch events, where you can’t assume there’s a single global mouse pointer. Since you’ve been got a mouse event to work with, e.getEventRelativeTo (parent).getPosition() would be a more robust way of getting the value you want, or better still, use e.getDistanceFromDragStartX().

Since we’re on the subject, is this the right way to do it? Knob is my own Component derived class that implements a “rotary slider.” The mouse disappears when you operate the knob. Mouse movement in the X axis allows for large changes in the knob, while movement in the Y axis allows fine-tune changes to the knob.

Specifically, I’m using “e.source” is that the right way? Do I care about multi-touch?

void Knob::mouseDrag (const MouseEvent& e)
{
  e.source.enableUnboundedMouseMovement( true );

  double value = m_startValue
    + e.getDistanceFromDragStartX()/1500.
    - e.getDistanceFromDragStartY()/250.;

  if( value > 1 )
  {
    m_startValue -= value - 1;
    value = 1;
  }
  else if( value < 0 )
  {
    m_startValue -= value;
    value = 0;
  }

  notifySetValue( value );
}