From d78cbb79c98e01fc524ec91fb099ec8ff98cc1fa Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 4 Jun 2020 23:54:22 +0200 Subject: [PATCH] Fix/Workaround file where we can't enter values in some fields The problem was that the JS checker for the field format was using the willCommit property of event and we don't define it so the JS interpreter was going "ok nope, out of here" and the field didn't get edited. I've read the willCommit definition in js_api_reference.pdf for almost 30 minutes, and even it's just 3 lines i don't think i understand it, but i think that returning true is "safer", i.e. says that this event is going to actually change the field, which as far as i can see it's what we always do BUGS: 421508 --- core/script/kjs_event.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/script/kjs_event.cpp b/core/script/kjs_event.cpp index 94bbba3d6..06eec803d 100644 --- a/core/script/kjs_event.cpp +++ b/core/script/kjs_event.cpp @@ -121,6 +121,13 @@ static void eventSetReturnCode( KJSContext *ctx, void *object, KJSObject value ) event->setReturnCode ( value.toBoolean ( ctx ) ); } +// Event.willCommit (getter) +static KJSObject eventGetWillCommit( KJSContext *, void */*object*/ ) +{ + // TODO Someone try to understand the defintion of willCommit better from js_api_reference.pdf + return KJSBoolean( true ); +} + void JSEvent::initType( KJSContext *ctx ) { static bool initialized = false; @@ -138,6 +145,7 @@ void JSEvent::initType( KJSContext *ctx ) g_eventProto->defineProperty( ctx, QStringLiteral( "shift" ), eventGetShift ); g_eventProto->defineProperty( ctx, QStringLiteral( "source" ), eventGetSource ); g_eventProto->defineProperty( ctx, QStringLiteral( "target" ), eventGetTarget ); + g_eventProto->defineProperty( ctx, QStringLiteral( "willCommit" ), eventGetWillCommit ); g_eventProto->defineProperty( ctx, QStringLiteral( "value" ), eventGetValue, eventSetValue ); g_eventProto->defineProperty( ctx, QStringLiteral( "rc" ), eventGetReturnCode, eventSetReturnCode ); }