Overview
JDraggableField extends JSidebarItem to create draggable field items for use with JDesignCanvas. It enables drag-and-drop field assignment in label design applications.Constructor
Unique identifier for the field (e.g.,
"customer_name")- Used as drag data payload
- Typically lowercase with underscores
Display name shown in the sidebar (e.g.,
"Customer Name")- Human-readable label
- Shown with the icon
Icon displayed next to the field name
- Can be
nullfor no icon - Rendered as SVG graphic
Properties
Returns the field’s unique identifier
Returns the field’s display name
Drag Behavior
Automatic Drag Detection
- Drag starts on mouse press + drag gesture
- Transfer mode:
COPY(does not remove source) - Drag view: Snapshot of the field item
- Clipboard content: The
fieldIdstring
Drag Data
When dragged, the component places thefieldId in the dragboard:
Example Usage
Creating Draggable Fields
Organizing in Sidebar
Complete Label Designer
Programmatic Field Data
Styling
Style classes:.j-draggable-field- Main container- Inherits all styles from
JSidebarItem
Integration with JDesignCanvas
The canvas automatically handles dropped fields:Notes
- Extends
JSidebarItemfor consistent sidebar appearance - Drag snapshot provides visual feedback during drag
- Field remains in sidebar after drag (copy mode)
- Can be used with any drop target that accepts string data
- Icon is optional (pass
nullfor text-only fields) - fieldId should be unique within the field set