blockly | The web-based visual programming editor | Editor library
kandi X-RAY | blockly Summary
kandi X-RAY | blockly Summary
Google's Blockly is a library that adds a visual code editor to web and mobile apps. The Blockly editor uses interlocking, graphical blocks to represent code concepts like variables, logical expressions, loops, and more. It allows users to apply programming principles without having to worry about syntax or the intimidation of a blinking cursor on the command line. All code is free and open source.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create the JSON output .
- Return the fields of a block .
- Generate chunk options
- Return content of block fields .
- Update preview state
- Update the block .
- Creates JS code to generate content .
- Initializes the Blockly .
- open window
- Sort requires .
blockly Key Features
blockly Examples and Code Snippets
Community Discussions
Trending Discussions on blockly
QUESTION
I'm working on an Android app that allows non-programmers to program an educational robot using a visual programming language (Blockly based). This robot runs a lua virtual machine and can set up his own wifi network which I will connect to from my Android device.
The problemI need to send the code to the robot and I need to do this from inside the Android webview because it's important that the user can continue to see the block-based program while the robot executes it and sends back feedback to the mobile device (which will highlight the code blocks being executed in real time). So basically: I need to send and receive data from inside an Android webview through a raw tcp socket using my own communication protocol.
What have I tried?I've been searching information on how to solve this. So far I've learnt:
- Plain javascript: you can only use websockets which work with http protocol and don't support my custom protocol.
- React native: I think it would enable me to solve this since it's node.js based and node.js offers libraries that support raw sockets. (Discarded because apparently react native doesn't use webview)
- Androidjs: it's a framework that apparently would let me use node.js on my android app, the problem with this framework is that it doesn't seem to be very popular and the github seems to be a little abandoned, not sure if I should use this. Another problem is that I am not 100% clear on if it allows me use node.js packages inside the android webview.
ANSWER
Answered 2022-Feb-24 at 02:54I didn't find a way to use raw tcp sockets inside the webview.
However I was able to work around this problem binding a javascript interface to my webview which allows communication between the webview and the interface (a Java class), then in the interface I implemented the tcp socket easily since it's Java.
JavascriptInterface info: https://developer.android.com/guide/webapps/webview.html#BindingJavaScript
The way I used to communicate from Android to the webview was defining a javascript function in the js file running inside my webview, let's call it "myJsFunction()", which will be called using the WebView's loadurl() method, like this:
QUESTION
I only found https://groups.google.com/g/blockly/c/SDUosMpAFAk to my problem, but it has no answers that could help me, so I created a Codesandbox to reproduce the behavior.
https://codesandbox.io/s/gallant-galois-bqjjb
The button in the Sandbox will open a modal with a Blockly Canvas in it. Trying to write something in the "text"- or "math_number"-Block does not work, and when you close the modal, with an outside click, some artifacts are staying.
I would be glad if someone can help me out with this.
EDIT: In case of the CodeSandbox link is not working.
Dependencies:
- @material-ui/core: 4.12.3
- @material-ui/styles: 4.11.4
- blockly: 6.20210701.0 (6.20210701.0)
- react: 17.0.2
- react-dom: 17.0.2
- react-scripts: 4.0.0
- react-use: 17.3.1
CODE:
index.js
...ANSWER
Answered 2021-Dec-07 at 15:57You can set the property disableEnforceFocus
to true
, and that will solve the problem for the input text/number blocks. However the problem persists for blocks using selection elements (e.g. logic_compare
, math_arithmetic
).
QUESTION
I am developing a simple game (similar to Blockly and Scratch) that involves drag and drop. Currently, I am able to drag the button to a target container. However, the button gets completely transferred to another container. What I want to achieve is something like copy-pasting - from one container to another (basically drag-and-copy). I understand I have to clone it and give it a new ID but to no avail.
Here are the relevant codes: HTML and JS
...ANSWER
Answered 2021-Nov-27 at 17:12You need to clone the dragged html element:
So your code should be:
QUESTION
I've been trying to make a custom block in the Blockly workspace that changes the options in drop-down fields based on the selection of a previous drop-down field in the same block. About the block:-
- There are three dropdown fields
- All are populated dynamically using Blockly.Extensions
- All codes are present below
I've implemented an 'onchange' function to the blockly initialization that gets the change data through the 'event' variable and responds accordingly. I'm having problems trying to update the changing drop-down fields. Please assist.
Code
...ANSWER
Answered 2021-Apr-25 at 03:31Thanks to @beka from Google Blockly groups at https://groups.google.com/g/blockly.
The main problem here was conceptual. A block has
- inputs: field rows that can have anything like value blocks (puzzle piece input) or statement blocks (lego input)
- fields: like from HTML. these can be text boxes, drop-downs, images, etc.
Both the input and the field can have names. And it is good practice to name them differently.
As seen in my extensions, I'd taken my input this.getInput('columnInput')
and appended a field .appendField
with the same name. Due to this, the input had a field with the same name.
Here are the corrections:
- to the extensions:
QUESTION
I am developing an app with ionic and angular. In one specific page I added a component into the ion-content, however now I want to choose to display another one when I click a button. I have been looking for an option but it has been imposible for me to find how to do it. This is my actual code:
...ANSWER
Answered 2021-Apr-23 at 07:52define your boolean properties to show components or not:
QUESTION
First, I imported DomSanitizer to the component:
...ANSWER
Answered 2021-Mar-09 at 12:34Since you're going out of the Angular
flow of binding events, you can add the event listener in two ways to take care of the correct this
:-
Arrow functions (inside ngOnInit
) :-
primaryWorkspace.addChangeListener((event)=>this.updateURL(event));
.bind
(inside constructor
) :-
this.updateURL = this.updateURL.bind(this);
And in ngOnInit
:-
primaryWorkspace.addChangeListener(this.updateURL);
Also I think you meant addEventListener('change',...
) instead of addChangeListener
.
QUESTION
The question says that:
The program shown below on the left draws a snowflake. It uses 33 code blocks. Can you re-write it so that it uses at least one function and less than 30 blocks.
How can I draw this using Blockly?
...ANSWER
Answered 2021-Feb-15 at 11:37After some research I don't think recursive function is the solution in this case but in python I would try something like this
QUESTION
My son and I are trying to implement one of the fun-science.org microbit tutorials - building a "tug of war" game. Essentially, 10 presses on button A moves the sprite closer to that button and the same applies on button B. When you hit the edge of the screen, music plays and a message is scrolled on the screen before the game restarts.
We've got it fully working, but once the game has been won, it doesn't seem to reset properly. It works fine on the simulator, but not on the physical device (a microbit 2).
Once the game is won, the behaviour is erratic. It usually puts the sprite back in the middle, sometimes not, but frequently, one button doesn't work in the next game. Occasionally both stop working. In every situation, a restart fixes things.
Is there something wrong with the code? I've wondered whether the music / message is corrupting something and I need to put a wait in for it to complete. I've re-downloaded the hex file and re-flashed the microbit several times, so I think I've eliminated a corrupt code file.
Javascript version of code shown below, but it was actually built in blockly using the Microsoft MakeCode tool.
...ANSWER
Answered 2021-Jan-02 at 16:12I found it was more reliable if I did game.pause() and game.resume() while scrolling the text and playing the music at the end of the game:
QUESTION
I have a situation where I generate code from within a Blockly component. The resulting code will have a function that I want to call. According to the Blockly "Generating and Running JavaScript" documentation, I should use eval()
.
When I look up eval()
on MSDN, I get a section that I should "never use eval" and use Function
instead.
Here is some example code from what the output of the code could be:
...ANSWER
Answered 2020-Dec-27 at 17:35Following Function
document link, you should define function just from code lines, not include something like function XXXXX() {}
So, it should be
QUESTION
I'm new into Flutter and I'm trying to add Blockly into Flutter for an app for kids. I want to be able to program some code into a Flutter app with Blockly, practically I'm trying to create a route with inside a Blockly widget in which the kid, through Blockly, can codes some simple programs and these are used by the Flutter app to do something.
...ANSWER
Answered 2020-Dec-01 at 00:00If I understood right, you want to use Blockly as a widget inside your app. A way to do that is to create a route that has a WebView widget in order to display Blockly:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install blockly
Getting Started article
Getting Started codelab
More codelabs
Demos and plugins
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page