Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.0 Beta 1, 5.12
-
None
Description
main.qml:
import QtQuick 2.12 import QtQuick.Window 2.12 //import './app.js' as App // works fine import './app.mjs' as App // produces error Window { visible: true width: 720 height: 480 title: qsTr("Keys") Rectangle { id: rect anchors.fill: parent focus: true Keys.onPressed: { console.log('qml.rect.Keys.onPressed', event.key) } } Component.onCompleted: { App.main(rect) // inconsistent behavior here } }
app.mjs:
export function main(rect) { console.log('mjs.rect.Keys', rect.Keys); // prints undefined console.log('mjs.rect.Component', rect.Component); // prints undefined rect.Keys.pressed.connect((e) => { // throws TypeError console.log('mjs.rect.Keys.pressed', e.key); }); }
app.js:
function main(rect) { console.log('js.rect.Keys', rect.Keys); // prints QQuickKeysAttached(...) console.log('js.rect.Component', rect.Component); // prints QQmlComponentAttached(...) rect.Keys.pressed.connect((e) => { // emit events console.log('js.rect.Keys.pressed', e.key); }); }