When the elements in the report designer are dragged, the behavior of Jaspersoft Studio is similar to most graphical designers. When you drag an element inside a band, or a frame, you expect that the element will change its parent. This happens in most of the cases. But there are some special cases where this doesn't happen. In this tutorial we will examine some of these cases and also some keys that can change the default behavior.
Elements from different container
When you select one or more elements from a container, you can move them with the default behavior. So, if the drop is done in the same container, then only the position changes, otherwise it will be changed also for the container. But if the selection contains elements from different containers, you can only change the position. So even if you drop the selection on a container, all the elements will keep their original parent and will only change their position relative to it.
Elements contained inside frame
Starting from JasperReports 6.1.1, the behavior of the frame elements will change. They will be similar to Subreports and, because of this, the size of a frame will not matter anymore on how its content is painted. For this reason the elements inside a frame can be placed outside it without causing errors. To support this, a modifier was added inside Jaspersoft Studio that acts when the dragged elements are contained in a frame. In this case, the dragged elements will never change parent, even if the selection contains elements that are all contained inside the frame. Since an element of the frame can be placed outside of its boundary, there is no way to know if the user wanted to drag an element outside of the frame and change containers or only move an element that is placed outside the boundary. We choose as default behavior that in this case the element doesn't change parent anymore.
Override this behaviour
There are two way to override this behaviour and have the dragged elements moved inside the container where they are dropped.
- Keep pressed the A key while dragging: Keeping the A key pressed during the drag operation will always change the container of the selected elements to the container where they are dropped.
- Drag & Drop in the outline: these drag and drop modifiers are applied only on the visual editor, so every drag and drop operation done in the outline will always move the elements to the container where they are dropped. This is because, in the outline, it is easier to distinguish clearly what the user wants to do, since it doesn't allow editing the positions of the elements, we can determinate that each drag over a container wants to change the parent of the selection to that container.
Other keyboard modifiers
Another useful keyboard modifier is the SHIFT key. When this button is kept pressed during the drag operation, it allows only straight vertical or horizontal movements of the selected elements. Also it allows only one of these directions, so you will be able to move your selection only straight horizontally if after you pressed the SHIFT key the first movement is on the horizontal axis, otherwise if is on the vertical axis only straight vertical movement of the selection are allowed. You can return to the default behavior simply by releasing the SHIFT key, also during the same drag operation.
Log in or register to post comments