Skip to content

Delete variable#2143

Closed
alschmiedt wants to merge 2 commits intoRaspberryPiFoundation:developfrom
alschmiedt:delete_variable
Closed

Delete variable#2143
alschmiedt wants to merge 2 commits intoRaspberryPiFoundation:developfrom
alschmiedt:delete_variable

Conversation

@alschmiedt
Copy link
Contributor

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

Resolves

#1105

Proposed Changes

Adds a delete button to the default variables toolbox category.
screen shot 2018-11-28 at 2 51 34 pm

Reason for Changes

There was no way before to delete a variable without dragging it into the workspace.

Test Coverage

Tested on:

Additional Information

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

*/
Blockly.Variables.deleteVariableButtonHandler = function(workspace) {
var promptAndCheckWithAlert = function(defaultName) {
Blockly.Variables.promptName(Blockly.Msg['DELETE_VARIABLE_PROMPT'], defaultName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using the existing text field prompt can you make one with a dropdown with all existing variables?

};

/**
* Helper function to create a button for the flyout window.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this creates the XML for the button, not the button itself. That's because the XML then gets passed into the flyout code, which creates the button onscreen.

@samelhusseini
Copy link
Contributor

Just throwing this out in case you find this helpful, but another way to achieve this without having another button in the flyout could be to use the variables_get context menu and have a delete option there. So a user could open the variables flyout and right click on the variable they're trying to delete and delete it. You already have the list of variables visible to the user to select which they're trying to delete.

@rachel-fenichel
Copy link
Collaborator

rachel-fenichel commented Nov 29, 2018

@samelhusseini I like that plan, and I think it also matches what Scratch does.

@alschmiedt, @RoboErikG, thoughts? It seems more elegant than the alternatives.

@samelhusseini
Copy link
Contributor

Yep. I've added both the option to rename and delete. Not sure about @scratch

@alschmiedt
Copy link
Contributor Author

This sounds good to me as well. Thanks for the suggestion.

@RoboErikG
Copy link
Contributor

SGTM. Thanks, Sam. =)

@AnmAtAnm
Copy link
Contributor

While the context menus work in touch, I see very few people perform the long press to activate them. I think there is a solid use case for a more visible deletion mechanism in the variables UI.

@alschmiedt
Copy link
Contributor Author

Some thoughts for a more visible delete buttons.
If we had all the time in the world we would want to create an x to the right of the variables in the flyout.
Another (more time convenient) option would be to create a deleteAllUnusedVariables function. This would allow developers the ability to create a deleteVariables button in the flyout if necessary.

@alschmiedt alschmiedt closed this Feb 7, 2019
@alschmiedt alschmiedt deleted the delete_variable branch June 10, 2019 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants