Giter VIP home page Giter VIP logo

Comments (5)

roroettg avatar roroettg commented on June 18, 2024

Hi,

as lot has changed since then, unfortunately the docs are not up to date.

  1. NgxToolboxBuilderService is obsolete.

Do it like this

        const workspace = new Blockly.WorkspaceSvg(new Blockly.Options({}));
        const toolbox: NgxBlocklyToolbox = new NgxBlocklyToolbox(workspace);
        toolbox.nodes = [
            LOGIC_CATEGORY,
            new Category('bla', '#ff0000', [...this.customBlocks, this.button, this.label]),
            LOOP_CATEGORY,
            MATH_CATEGORY,
            TEXT_CATEGORY,
            LISTS_CATEGORY,
            COLOUR_CATEGORY,
            new Separator(),
            VARIABLES_CATEGORY,
            FUNCTIONS_CATEGORY,
            LOGIC_CATEGORY,
            new Category('bla', '#ff0000', [...this.customBlocks, this.button, this.label]),
            LOOP_CATEGORY,
            MATH_CATEGORY,
            TEXT_CATEGORY,
            LISTS_CATEGORY,
            COLOUR_CATEGORY,
            new Separator(),
            VARIABLES_CATEGORY,
            FUNCTIONS_CATEGORY,
            LOGIC_CATEGORY,
            new Category('bla', '#ff0000', [...this.customBlocks, this.button, this.label]),
            LOOP_CATEGORY,
            MATH_CATEGORY,
            TEXT_CATEGORY,
            LISTS_CATEGORY,
            COLOUR_CATEGORY,
            new Separator(),
            VARIABLES_CATEGORY,
            FUNCTIONS_CATEGORY
        ];
        this.config.toolbox = toolbox.toXML();
  1. The blockly config has been changed
 public config: NgxBlocklyConfig = {
        ...
        move: {
            scrollbars: true,
            wheel: true
        }
  1. Category constructor has been changed
new Category('bla', '#ff0000', [CustomBlockA, CustomBlockB]);

from ngx-blockly.

fjaen avatar fjaen commented on June 18, 2024

Thank you very much. Your suggestions solved the problem. I have an additional problem with fields. This code generates compilation errors:

const field = this.block.getField("GAME_OBJECTS");
if (this.mode)
field.menuGenerator_=TypeUtils.getInstances(this.unitytype);
else field.menuGenerator_=[['self','self'],['event_source','event_source']].concat(TypeUtils.getInstances(this.unitytype));
field.setValue(field.getOptions()[0][1]);

because field has no menuGenerator_ property and no getOptions() method

Thanks again for your help
J.

from ngx-blockly.

roroettg avatar roroettg commented on June 18, 2024

In this case you probably need to cast the Object to FieldDropdown since getField does return Blockly.Field

from ngx-blockly.

fjaen avatar fjaen commented on June 18, 2024

Thanks for your quick answer. This is producing a side effect because if I import
Blockly from 'ngx-blockly'

to do the casting:
const field = this.block.getField("GAME_OBJECTS") as Blockly.FieldDropdown;

then another part of my code is broken:

return [this.block.getFieldValue('GAME_OBJECTS'),Blockly.Lua.ORDER_ATOMIC];
because now BLockly has no Lua property.

In my previous code Blockly was defined as
declare var Blockly: any;

I apologize if I did not explain my problem correctly.
Best
J.

from ngx-blockly.

fjaen avatar fjaen commented on June 18, 2024

I solved this by importing Blockly with an Alias
Thanks

from ngx-blockly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.