How to use the babylonjs-editor.Dialog.CreateWithTextInput function in babylonjs-editor

To help you get started, we’ve selected a few babylonjs-editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BabylonJS / Editor / src / editor / components / assets.ts View on Github external
this.contextMenu.tree.onClick = async (id) => {
            // Custom callback?
            const customItem = items.find(i => i.callback && i.id === id);
            if (customItem) {
                customItem.callback(asset);
                return this.contextMenu.hide();
            }

            switch (id) {
                // Rename the asset
                case 'rename':
                    if (!component.onRenameAsset)
                        return;
                    
                    const oldName = asset.name;
                    const newName = await Dialog.CreateWithTextInput('New asset name');

                    asset.name = newName;
                    component.onRenameAsset(asset, newName);

                    UndoRedo.Push({
                        fn: (type) => {
                            if (type === 'from')
                                component.onRenameAsset(asset, oldName);
                            else
                                component.onRenameAsset(asset, newName);

                            this.refresh();
                            this.showTab(component.id);
                        }
                    });
                    break;
github BabylonJS / Editor / src / tools / behavior / graph.ts View on Github external
protected async add (): Promise {
        // Configure
        GraphExtension.ClearNodes();
        GraphExtension.RegisterNodes(this.node);

        // Create data
        const name = await Dialog.CreateWithTextInput('Graph Name');
        const data: BehaviorGraph = {
            name: name,
            active: true,
            graph: new LGraph().serialize()
        };
        this.datas.metadatas.push(data);

        // Add to grid
        this.grid.addRow({
            recid: this.datas.metadatas.length - 1,
            name: data.name,
            active: true
        });

        // Select latest script
        this.grid.select([this.datas.metadatas.length - 1]);
github BabylonJS / Editor / src / editor / components / assets.ts View on Github external
public async addAsset (component?: IAssetComponent): Promise> {
        if (!component)
            component = this.currentComponent;

        if (component && component.onCreateAsset) {
            const name = await Dialog.CreateWithTextInput('New asset name');
            const asset = await component.onCreateAsset(name);

            this.showTab(component.id);
            this.refresh(component.id);

            return asset;
        }

        return null;
    }