bq. Thanks again, your answers are so clear, this is so delightful and I am so eager to learn.
You're welcome, thank you. I'm glad that i can help you with your questions and encourage you.
bq. So if i understand well, there is a keyboard handler somewhere hidden
Well, yes. Keys is also just a Component like Rectangle and MouseArea. You can also try to write it like that ...
@Keys {
}@
... but your console/output will write: Keys is only available via attached properties. That means this Component can not be standalone and has to be written like a property in any Component you want.
bq. that triggers a signal as soon as a key is pressed and there is a slot by default that is onPressed that receive the signal and that triggers an action
Yes, it detects the key press as soon as we press a key and emits a signal based on which key it was. As you can see in the "Keys":http://qt-project.org/doc/qt-4.8/qml-keys.html Documentation, there are several signals handlers. A signal handler is just the slot/notificator i explained in a post above. Let's take the "onDigit9Pressed":http://qt-project.org/doc/qt-4.8/qml-keys.html#onDigit9Pressed-signal slot/nofiticator as our example.
We press the Key 9
Our Keys Component receives the event and checks which signals it can emit: onDigit9Pressed and onPressed (Remind! This are just the slots of the signals, the signals it would emit would be: digit9Pressed(KeyEvent event) and pressed(KeyEvent event))
It sees that we have got a slot connected to the signal, that would be the onPressed slot(I took your Application as an example for that because we have got a onPressed: slot there).
The signal emits the slot and everything after the colon would be the code to execute.
bq. So my question is a little bit tricky? Where is the Pressed() signal?
The pressed(KeyEvent event) signal is hidden in the Keys Component. Kind of like we created our signal.
bq. is it by default in QtQuick? Is there no possibility of confusion?
It is by default part of a Component. And there is no confusion because each Component handles it's intern stuff by itself. You could create a pressed() signal in each Component. But the onPressed: slot would also be just part of the Component where the signal is, that means you can also have a onPressed event in each Component where the signal pressed() is and they wouldn't conflict. An exeption would be the top-level Component, the properties and signals defined in the top-level component are accessable from everywhere. The top-level Component is the first Component you have got:
@Rectangle { // Our top-level Component, there can be only one.
Text { // Children
...
}
MouseArea{ // Children
Text { // Children
...
}
...
}
...
}@