@@ -43,6 +43,7 @@ void SensingBlocks::registerBlocks(IEngine *engine)
4343 engine->addCompileFunction (this , " sensing_askandwait" , &compileAskAndWait);
4444 engine->addCompileFunction (this , " sensing_answer" , &compileAnswer);
4545 engine->addCompileFunction (this , " sensing_keypressed" , &compileKeyPressed);
46+ engine->addCompileFunction (this , " sensing_mousedown" , &compileMouseDown);
4647}
4748
4849void SensingBlocks::onInit (IEngine *engine)
@@ -167,6 +168,11 @@ CompilerValue *SensingBlocks::compileKeyPressed(Compiler *compiler)
167168 return compiler->addFunctionCallWithCtx (" sensing_keypressed" , Compiler::StaticType::Bool, { Compiler::StaticType::String }, { key });
168169}
169170
171+ CompilerValue *SensingBlocks::compileMouseDown (Compiler *compiler)
172+ {
173+ return compiler->addFunctionCallWithCtx (" sensing_mousedown" , Compiler::StaticType::Bool);
174+ }
175+
170176void SensingBlocks::onAnswer (const std::string &answer)
171177{
172178 // https://github.com/scratchfoundation/scratch-vm/blob/6055823f203a696165084b873e661713806583ec/src/blocks/scratch3_sensing.js#L99-L115
@@ -328,3 +334,8 @@ extern "C" bool sensing_keypressed(ExecutionContext *ctx, const StringPtr *key)
328334 std::string u8name = utf8::utf16to8 (std::u16string (key->data ));
329335 return ctx->engine ()->keyPressed (u8name);
330336}
337+
338+ extern " C" bool sensing_mousedown (ExecutionContext *ctx)
339+ {
340+ return ctx->engine ()->mousePressed ();
341+ }
0 commit comments