EventCopyPaste
Feature
Allow using Ctrl/Cmd+C, Ctrl/Cmd+X and Ctrl/Cmd+V to copy/cut and paste events.
This feature also adds entries to the EventMenu for copying & cutting (see example below for how to configure) and to the ScheduleMenu for pasting.
You can configure how a newly pasted record is named using generateNewName.
If you want to highlight the paste location when clicking in the schedule, consider enabling the ScheduleContext feature.
This feature is enabled by default.
Customize menu items
See EventMenu and ScheduleMenu for more info on customizing the menu items supplied by the feature. This snippet illustrates the concept:
// Custom copy text + remove cut option from event menu:
const scheduler = new Scheduler({
features : {
eventMenu : {
items : {
copyEvent : {
text : 'Copy booking'
},
cutEvent : false
}
}
}
});
Keyboard shortcuts
The feature has the following default keyboard shortcuts:
| Keys | Action | Action description |
|---|---|---|
| Ctrl+C | copy | Copies selected event(s) into the clipboard. |
| Ctrl+X | cut | Cuts out selected event(s) into the clipboard. |
| Ctrl+V | paste | Insert copied or cut event(s) from the clipboard. |
For more information on how to customize keyboard shortcuts, please see our guide.
Multi assigned events
In a Scheduler that uses single assignment, copying and then pasting creates a clone of the event and assigns it to the target resource. Cutting and pasting moves the original event to the target resource.
In a Scheduler using multi assignment, the behaviour is slightly more complex. Cutting and pasting reassigns the event to the target, keeping other assignments of the same event intact. The behaviour for copying and pasting is configurable using the copyPasteAction config. It accepts two values:
'clone'- The default, the event is cloned and the clone is assigned to the target resource. Very similar to the behaviour with single assignment (event count goes up by 1).'assign'- The original event is assigned to the target resource (event count is unaffected).
This snippet shows how to reconfigure it:
const scheduler = new Scheduler({
features : {
eventCopyPaste : {
copyPasteAction : 'assign'
}
}
});
Native/shared clipboard
If you have multiple Schedulers (or other Bryntum products) on the same page, they will share clipboard. This makes it possible to copy and paste between different Scheduler instances. It is also possible to use the native Clipboard API if it is available and if you set useNativeClipboard to true.
Regardless of native clipboard availability, copy-pasting "outside" of the current Scheduler instance will convert the copied events to a string. When pasting, the string will then be parsed back into events. In case of usage of the native Clipboard API, this means it is possible to copy and paste events between completely different applications.
To configure the fields that is converted and parsed from the copied string value, please see the eventToStringFields config.
Useful configs and functions
| Member | Description |
|---|---|
| beforeCopy | Fires before copy, return false to prevent |
| copy | Fires when events are copied |
| beforePaste | Fires before paste, return false to prevent |
| paste | Fires when events are pasted |
See also
- EventModel - Event data model
- EventEdit - Event editor
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
The field to use as the name field when updating the name of copied records
-
By default, pasting of multiple events will spread out according to the pattern it was copied. Set to
falseto paste into the same resource and same date.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of EventCopyPaste class, or subclass thereof.
-
Identifies an object as an instance of EventCopyPaste class, or subclass thereof.