BlocklyController.VariableCallback

public static abstract class BlocklyController.VariableCallback extends Object
Known Direct Subclasses

Callback for handling requests to modify the list of variables. This can be used to show a confirmation dialog when deleting a variable, or customize the UI shown for creating/editing a variable.

Public Constructor Summary

Public Method Summary

abstract void
onAlertCannotDeleteProcedureArgument(String variableName, VariableInfo info)
Sent when a user attempts to delete a variable that is used as a procedure argument.
boolean
onCreateVariable(String varName)
Sent when the user tries to create a new variable.
boolean
onDeleteVariable(String variable, VariableInfo info)
Sent when the user tries to remove a variable.
boolean
onRenameVariable(String variable, String newVariable)
Sent when the user tries to rename a variable.

Inherited Method Summary

Public Constructors

public BlocklyController.VariableCallback ()

Public Methods

public abstract void onAlertCannotDeleteProcedureArgument (String variableName, VariableInfo info)

Sent when a user attempts to delete a variable that is used as a procedure argument.

Parameters
variableName The name of the variable.
info The info for this variable.

public boolean onCreateVariable (String varName)

Sent when the user tries to create a new variable. If true is returned a variable will be created with the next available default name. If callers wish to modify and then create a variable they should return false and then call addVariable(String) with the new variable and forced set to true.

Parameters
varName The initial variable name or null if no starting name was specified.
Returns
  • True to create the named variable, false to handle it yourself.

public boolean onDeleteVariable (String variable, VariableInfo info)

Sent when the user tries to remove a variable. If true is returned the variable and any blocks referencing it will be deleted.

Parameters
variable The variable being deleted.
info
Returns
  • True to allow the delete, false to prevent it.

public boolean onRenameVariable (String variable, String newVariable)

Sent when the user tries to rename a variable. There is no default handling for variable renaming in the controller, so an application must override this to support renaming variables.

Parameters
variable The variable to rename.
newVariable The new name for the variable.
Returns
  • True to perform the rename, false to handle it yourself.