Exemplo n.º 1
0
        /**
         * Block for defining a procedure with a return value.
         * @this Blockly.Block
         */
        public override void init()
        {
            var nameField = new FieldTextInput(
                Msg.PROCEDURES_DEFRETURN_PROCEDURE);

            nameField.setValidator((filed, str) => { return(Core.Procedures.rename(nameField, str)); });
            nameField.setSpellcheck(false);
            this.appendDummyInput()
            .appendField(Msg.PROCEDURES_DEFRETURN_TITLE)
            .appendField(nameField, "NAME")
            .appendField("", "PARAMS");
            this.appendValueInput("RETURN")
            .setAlign(Core.ALIGN_RIGHT)
            .appendField(Msg.PROCEDURES_DEFRETURN_RETURN);
            this.setMutator(new Mutator(new[] { ProceduresMutatorargBlock.type_name }));
            if ((this.workspace.options.comments ||
                 (this.workspace.options.parentWorkspace != null &&
                  this.workspace.options.parentWorkspace.options.comments)) &&
                !String.IsNullOrEmpty(Msg.PROCEDURES_DEFRETURN_COMMENT))
            {
                this.setCommentText(Msg.PROCEDURES_DEFRETURN_COMMENT);
            }
            this.setColour(Core.Procedures.HUE);
            this.setTooltip(Msg.PROCEDURES_DEFRETURN_TOOLTIP);
            this.setHelpUrl(Msg.PROCEDURES_DEFRETURN_HELPURL);
            this.arguments_ = new JsArray <string>();
            this.setStatements_(true);
            this.statementConnection_ = null;
        }
Exemplo n.º 2
0
        /**
         * Mutator block for procedure argument.
         * @this Blockly.Block
         */
        public override void init()
        {
            var field = new FieldTextInput("x", this.validator_);

            this.appendDummyInput()
            .appendField(Msg.PROCEDURES_MUTATORARG_TITLE)
            .appendField(field, "NAME");
            this.setPreviousStatement(true);
            this.setNextStatement(true);
            this.setColour(Core.Procedures.HUE);
            this.setTooltip(Msg.PROCEDURES_MUTATORARG_TOOLTIP);
            this.contextMenu = false;

            // Create the default variable when we drag the block in from the flyout.
            // Have to do this after installing the field on the block.
            field.onFinishEditing_ = this.createNewVar_;
            field.onFinishEditing_("x");
        }