Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadow blocks custom context menu #8615

Open
1 task done
FranciscoCaetano88 opened this issue Oct 9, 2024 · 3 comments
Open
1 task done

Shadow blocks custom context menu #8615

FranciscoCaetano88 opened this issue Oct 9, 2024 · 3 comments
Labels
issue: feature request Describes a new feature and why it should be added

Comments

@FranciscoCaetano88
Copy link

Check for duplicates

  • I have searched for similar issues before opening a new one.

Problem

I'm working on creating a function block using the new version of Blockly, where users can dynamically add or remove multiple arguments that themselves are shadow blocks. Most blocks shouldn't be able to connect to this inputs but there are a few exceptions. I've also implemented a custom dragging strategy that allows new argument blocks to be created by dragging this shadow argument blocks.

Now, I wanted to enhance the shadow blocks by adding a context menu that allows users to edit or remove the selected block. However this is not possible due to a rule in the gesture class that makes the target of every shadow block its parent. I experimented with making the argument blocks non-movable instead of using shadow blocks, but this approach didn’t work with the dragging strategy.

Request

I would like to be able to add a custom context menu to shadow blocks.

Alternatives considered

No response

Additional context

No response

@FranciscoCaetano88 FranciscoCaetano88 added issue: feature request Describes a new feature and why it should be added issue: triage Issues awaiting triage by a Blockly team member labels Oct 9, 2024
@cpcallen
Copy link
Contributor

Hi @FranciscoCaetano88. As I noted in our discussion in the forum, a better approach for your particular situation is probably to make the blocks non-shadow and modify the dragging strategy to work accordingly. That said, however:

The request that it be possible to access a block's context menu even when that block is a shadow seems reasonable and I think we should consider making this change. At the moment it is not possible to access a shadow block's context menu, because when a gesture begins on a a shadow block, unless that gesture is a click, the gesture is instead treated as targeting the parent block; to make it possible to access the context menu this gesture would also have to be excepted from the target-parent rule too, and as this would be a breaking change it will require some careful consideration to ensure that it does not create unexpected difficulties.

Would you be able to provide some screenshots of your current use-case, to provide a clear explanation of how this feature would be useful to you?

@cpcallen cpcallen added PR: feature Adds a feature needs more info Waiting for developer response and removed issue: triage Issues awaiting triage by a Blockly team member labels Oct 11, 2024
@FranciscoCaetano88
Copy link
Author

Hi @cpcallen! My goal is to recreate this function block in the new Blockly version. I want to be able to add or remove arguments using the +/- buttons and also edit or delete specific arguments from any position within the list.
When I tried using non-shadow blocks as suggested, actions like copy/paste or undo/redo would result in an extra block being created. My theory is that this happens because a block is being created during the display update. Then, the block's state includes another block, connected to the input, that replaces the created one, which disconnects the initially created block, leading to the extra block. I'm unsure how to work around this issue.

Image

@cpcallen
Copy link
Contributor

Thanks for the information, @FranciscoCaetano88. As it happens, we will probably have to address this issue as part of the planned changes to keyboard navigation, which involve using the context menu to allow keyboard access to a variety of editing functions—see google/blockly-keyboard-experimentation#130 and google/blockly-keyboard-experimentation#130 and google/blockly-keyboard-experimentation#132.

@cpcallen cpcallen removed needs more info Waiting for developer response PR: feature Adds a feature labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: feature request Describes a new feature and why it should be added
Projects
None yet
Development

No branches or pull requests

2 participants