getNoteAtPosition problem

Hi guys,

I’m working on a keyscale object similar to this one:

I made class which inherits MidiKeyboardComponent to show the keyboard on the bottom.
I overrided the getKeyPosition function to create my own layout of the black and white keys.

I created another component which draws slider for all the keyscale values above each piano note. These values change by dragging around with the mouse. To link al the sliders to the correct piano key position I used the getKeyStartPosition() and the getNoteAtPosition() functions.
For flexible resizing I combined these two components in a new component and added a viewport which shows that component.

It is possible to drag around the sliders and to go out of the screen where the keyboard still exists (inside the viewport). But when I call the getNoteAtPosition function from the mouseDrag function inside the top component, that function returns -1 (I passed a point P(mouseX,0) to the function). That is because the getNoteAtPosition function checks with reallyContains() if the point that is passed is inside the component returns false. For now, I removed that statement which made my program run well but is there another solution? What was the reason that the reallyContains() statement was there?

Thanks in advance,