mirror of
https://gitlab.com/eql/EQL5.git
synced 2025-12-09 03:50:24 -08:00
"quick": rename "Lisp.fun()" to "Lisp.call()"; allow optionally passing JS "this" (a QQuickItem) as first argument;
This commit is contained in:
parent
9e09c38766
commit
2aee9968c6
14 changed files with 117 additions and 44 deletions
|
|
@ -11,32 +11,48 @@ Item {
|
|||
|
||||
// Please note:
|
||||
//
|
||||
// * to call lisp functions, use either Lisp.fun() or Lisp.apply();
|
||||
// * to call lisp functions, use either Lisp.call() or Lisp.apply();
|
||||
// use JS arrays for lists (can be nested);
|
||||
//
|
||||
// * return values can be nested Lisp lists or vectors, which will be converted to
|
||||
// nested JS arrays: they will be prepared in Lisp and passed to JS eval;
|
||||
//
|
||||
// * optionally pass 'this' (or any other item) as first argument to either
|
||||
// Lisp.call() or Lisp.apply(); it can then be accessed in Lisp via qml:*caller*;
|
||||
|
||||
// (1) call CL function
|
||||
console.log(Lisp.fun("format", false, "~R", 123))
|
||||
console.log(Lisp.call("format", false, "~R", 123))
|
||||
|
||||
// (2) call EQL function
|
||||
Lisp.fun("qmsg", "hello from QML")
|
||||
Lisp.call("qmsg", "hello from QML")
|
||||
|
||||
// (3) pass list argument
|
||||
console.log(Lisp.fun("x:join", ["11", "55"], ":"))
|
||||
console.log(Lisp.call("x:join", ["11", "55"], ":"))
|
||||
|
||||
// (4) nested list arguments
|
||||
// N.B: don't get fooled by the printed representation of the return value:
|
||||
// it's a nested JS array internally
|
||||
console.log(Lisp.fun("list", [[1, 2, 3], ["a", "b", "c"], 4, 5], 6, [[7, 8], 9]))
|
||||
console.log(Lisp.call("list", [[1, 2, 3], ["a", "b", "c"], 4, 5], 6, [[7, 8], 9]))
|
||||
|
||||
// (5) pass 'this' as first argument (can be accessed in Lisp via qml:*caller*)
|
||||
Lisp.call(this, "eql-user:show-properties-dialog")
|
||||
}
|
||||
|
||||
Text {
|
||||
id: label
|
||||
objectName: "label"
|
||||
|
||||
anchors.centerIn: parent
|
||||
color: "blue"
|
||||
text: "Lisp enabled QML"
|
||||
font.bold: true
|
||||
font.pixelSize: 32
|
||||
|
||||
NumberAnimation on rotation {
|
||||
from: 0; to: 360;
|
||||
easing.type: Easing.InOutElastic;
|
||||
duration: 3000;
|
||||
loops: Animation.Infinite;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue