Label::click() does not generate a mouseUp() call


#1

Hi,

I want to generate a click() on a Label component programmatically, for UI testing. Apart from the fact that I should not be doing this for UI testing and I should be recording the data instead which at the moment I cannot as we do not have a clean MVC implementation yet, is there any reason why generating a fake click this way fails to call mouseUp()

The alternative seems to be, to convert the Label center Point to global co-ordinates(screen co-ordinates?) using Component::localPointToGlobal() and generate a Windows Message using Windows APIs. But I would rather stay platform agnostic with Juce.


Monitor all Components for changes
#2

Currently this seems to do the trick if the Component is visible:

INPUT input;
input.type = INPUT_MOUSE;
input.mi.mouseData = 0;
input.mi.time = 0;
input.mi.dx = x*(65536 / GetSystemMetrics(SM_CXSCREEN)); //x being coord in pixels
input.mi.dy = y*(65536 / GetSystemMetrics(SM_CYSCREEN)); //y being coord in pixels

input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; //MOUSEEVENTF_MOVE;//MOUSEEVENTF_ABSOLUTE
SendInput(1, &input, sizeof(input));

input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN; //MOUSEEVENTF_MOVE;//MOUSEEVENTF_ABSOLUTE
SendInput(1, &input, sizeof(input));

input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP; //MOUSEEVENTF_MOVE;//MOUSEEVENTF_ABSOLUTE
SendInput(1, &input, sizeof(input));

MessageManager::getInstanceWithoutCreating()->runDispatchLoopUntil(1);

If the component has been already scrolled away such that its not visible currently then there is a mis-click.

Is there any way to force a Component to become visible? For example if its a Label at the top of a ViewPort and the ViewPort has been scrolled too much such that the Label is not currently visible.
Then calling something like Label::makeVisible() scrolls the ViewPort to make the label visible?