Thank you yfede (!) Well, the idea would be to reposition the whole thing–the DocumentWindow-MainWindow window along with its content–the Component-MainComponent window content, right?
If I may, I will further illustrate ‘the problem’ for you. We want to write a simple program. When running, the App will display the typical Hello! main window and a button.
In the window the user may press the button (TextButton Component) at anytime. Pressing it will move the window from one place to another onscreen.
That is it. That is the challenge. A program which can re-locate its window to a new place onscreen!
OK, let us write the code–following what the Juce Tutorials say:
First create a Main.cpp file. It contains a MainWindow (the DocumentWindow class). Inside we may include a statement like
centreWithSize(getWidth(), getHeight()); or
setBounds(0, 0, getWidth(), getHeight()); or
setBounds(50, 100, getWidth(), getHeight()); or even
setBounds(getX, getY, getWidth(), getHeight())
Now, we create a MainComponent.h file. It contains a MainComponent (the Component class). Inside the MainComponent constructor we write
setSize(400, 300); // Window size is 400,300
When running this program, we get the window onscreen. Initially, we can position the window at the screen center, or at any other place (0,0 or 100,50 etc.) as we please–no problem. We do that using the different statement-examples mentioned above (inside MainWindow code).
However, and this is the problem, we cannot change the position of the window when we press the button?! The reason being here, at MainComponent, we are allowed to issue only the setSize() method. We cannot issue setBounds() or setTopLeftPosition(). They simply do NOT work. Therefore, only size may be manipulated inside the MainComponent program–not position! Why?
That is major limitation. At MainComponent, we cannot write a button routine that changes the -seemingly fixed/frozen position- of the main window.
Any suggestions, yfede? Thanks!