Hi there!
How can I call the native event handler when using the scriptshell binding of the qt script binding generator?
I'm using the splendid qt script binding generator lab-project to make all qt classes fully scriptable. Through the scriptshells it allows binding a script function to otherwise inaccessible protected event handlers. In non script you would derive from the class to access these..
scriptcode:
a.setGeometry(50,50,200,100);
a.show();
a.event = function (event) {
print(event.type().toString());
};
scriptcode:
var a = new QWidget();
a.setGeometry(50,50,200,100);
a.show();
a.event = function (event) {
print(event.type().toString());
};
To copy to clipboard, switch view to plain text mode
This works perfectly, but it hides the native implementation. If you look into the generated scriptshell files of the generator:
from: ..\com_trolltech_qt_gui\qtscriptshell_QWidget.cpp
bool QtScriptShell_QWidget
::event(QEvent* arg__1
) {
QScriptValue _q_function = __qtscript_self.property("event");
if (!_q_function.isFunction() || QTSCRIPT_IS_GENERATED_FUNCTION(_q_function)
|| (__qtscript_self.propertyFlags("event") & QScriptValue::QObjectMember)) {
} else {
QScriptEngine *_q_engine = __qtscript_self.engine();
return qscriptvalue_cast<bool >(_q_function.call(__qtscript_self,
QScriptValueList()
<< qScriptValueFromValue(_q_engine, arg__1)));
}
}
from: ..\com_trolltech_qt_gui\qtscriptshell_QWidget.cpp
bool QtScriptShell_QWidget::event(QEvent* arg__1)
{
QScriptValue _q_function = __qtscript_self.property("event");
if (!_q_function.isFunction() || QTSCRIPT_IS_GENERATED_FUNCTION(_q_function)
|| (__qtscript_self.propertyFlags("event") & QScriptValue::QObjectMember)) {
return QWidget::event(arg__1);
} else {
QScriptEngine *_q_engine = __qtscript_self.engine();
return qscriptvalue_cast<bool >(_q_function.call(__qtscript_self,
QScriptValueList()
<< qScriptValueFromValue(_q_engine, arg__1)));
}
}
To copy to clipboard, switch view to plain text mode
So either the native or the script event handler is called. Now my question is, if I missed an obvious way to call the native event handler from script.
If thats not possible I'm thinking of changing the scriptshell-generator-code (..\generator\shellimplgenerator.cpp ) to call the native handler for all events that have not been accepted inside the script-method. That's easy enough, but I want to know, if there is an out-of-the-box way.
Thx!
Johannes
Bookmarks