I created a project with only a main.cpp and coded this, but nothing is shown on screen and paint func is never called:
class TrackerComponent : public Component
{
public:
TrackerComponent(String name) : Component(name) { setOpaque (false); }
void paint (juce::Graphics& g) override
{
g.setColour(Colours::black);
g.drawRect(getLocalBounds(), 3);
g.setFont(12);
g.drawText("x = " + String(Desktop::getMousePosition(). x) + " y = " + String(Desktop::getMousePosition().y), getLocalBounds(), Justification::centred);
}
};
class MouseTrackerApplication : public juce::JUCEApplication, public Timer
{
public:
MouseTrackerApplication() {}
const juce::String getApplicationName() override { return ProjectInfo::projectName; }
const juce::String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override { return true; }
void initialise (const juce::String& commandLine) override
{
tracker.addToDesktop(ComponentPeer::StyleFlags::windowHasDropShadow |
ComponentPeer::StyleFlags::windowIsTemporary |
ComponentPeer::StyleFlags::windowIgnoresKeyPresses |
ComponentPeer::StyleFlags::windowIgnoresMouseClicks);
startTimer(1);
}
void timerCallback() override
{
tracker.setBounds(Desktop::getMousePosition().x, Desktop::getMousePosition().y, 100, 50);
tracker.repaint();
}
void shutdown() override {}
void systemRequestedQuit() override { quit(); }
void anotherInstanceStarted (const juce::String& commandLine) override {}
private:
TrackerComponent tracker{"Tracker"};
};
I think also that (when it will work) it wold be ever in front of all that is displayed on screen, is it possible?