2017년 1월 15일 일요일

Backpack: copy and paste blocks to different screens and projects


The Backpack allows you to carry around blocks throughout your project repositories, allowing blocks to be transferred between projects and between screens.  The contents of the Backpack persist throughout an App Inventor session.  (NOTE:When you quit your App Inventor session or refresh the App Inventor page in the browser, the Backpack will be emptied -- i.e., re-initialized.)
Click here for a video demo.

How does Backpack work?

The Backpack is a copy-and-paste feature that works between projects and screens. The Backpack icon is located at the upper-right corner of the workspace.


Copying Blocks. Blocks from the workspace can be dragged and dropped into Backpack. This is the copy operation -- the blocks are copied (duplicated) in the backpack.  When blocks are dropped into the Backpack, an animation and sound will occur to confirm for the user that the operation was successful.
Viewing the Backpack Contents. The contents of the Backpack can be viewed by clicking on the its icon (upper right corner of the workspace).  A scrollable flyout will pull out from the right edge of the workspace, displaying the Backpack’s contents. The flyout of the Backpack works the same way as the flyouts in the Block drawers.
To close the flyout without pasting any blocks, you can click the workspace or click any empty space in the Backpack with no block highlighted. Note that if you click on a highlighted block in the flyout, that block will be pasted to the workspace.
Pasting Blocks.  Blocks can be pasted from the backpack into the current workspace by clicking on the Backpack icon (upper right corner of the workspace) and dragging the block from the flyout to the desired location in the workspace.  
As long as you do not close App Inventor, the blocks in the Backpack will be transferrable throughout your project repository and to other screens within the current project. When you refresh the browser, a new session of App Inventor will begin and the Backpack will be empty.  

Background Menus

In addition to the drag-and-drop functionality, a right-click on background menus on the blocks and on the workspace can be used to perform Backpack functions -- as shown in the following image.


[right click on a block] 


 [right click on the workspace] 

Right Click on Block

⦁ Add to Backpack: You can add this block and all of its contained blocks to the Backpack by doing a right-click on the block and selecting this option. The number in the parentheses indicates the total number of blocks in the backpack.

Right Click on Workspace Background

Paste All Blocks from BackPack: this will paste all the blocks from the Backpack to the current project. The number in the parenthesis indicates the total number of blocks in the backpack.

Copy All Blocks to Backpack: you can add all blocks in the current workspace to Backpack.

Empty the Backpack: you can empty the Backpack when you no longer need its blocks. NOTE: Currently the Backpack will be emptied when you exit App Inventor.  When you restart App Inventor, your Backpack will be empty.

What can be added to Backpack?

Function and procedure definitions.  These will be renamed if a duplicate definition exists in the destination workspace.
Lists, strings, and other data
Variable definitions and references.  Variable definitions will be renamed if a duplicate definition exists in the destination workspace.
Blocks Containing Components: Ideally, your destination project should have matching components with the same name or you will need to add components into the destination project after pasting from the Backpack. Reference to a non-existing component will cause red error triangles to be raised.



Initializations that duplicate existing blocks in the destination workspace will be automatically renamed.  For example, if you try to paste a variable initialization block for global variable X and the workspace already contains an initialization block for X, the variable will be renamed X2 in the pasted block.
Similarly, if you try to paste a procedure definition for procedure foo and the workspace already contains a definition of foo, the pasted procedure will be renamed foo2.
Can you paste blocks into any project or screen?
Yes. However, there are instances when pasting blocks from the backpack to a new project or screen will cause red error triangles  to be raised.  For example, this will occur when a block refers to a non-existent variable or procedure in the destination project. The errors can be removed (fixed) by defining the missing variable or procedure.  It will also occur when a block refers to a non-existent component in the destination project.  The errors can be removed (fixed) by adding the missing component and giving it the same name as the one referred to in the pasted block.



댓글 없음:

댓글 쓰기