Skip to content

Commit 3f26099

Browse files
committed
fix: Block event-clipboard paste into Camera Editor layer name field
1 parent ba98ece commit 3f26099

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

source/funkin/ui/debug/cameraeditor/CameraEditorState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ class CameraEditorState extends UIState implements ConsoleClass
23292329
hasClipboardEvent = true;
23302330
var removeCmds:Array<CameraEditorCommand> = [for (ev in selectedSongEvents) new RemoveEventCommand(ev)];
23312331
CameraEditorCommandHandler.performCommand(this, new CompoundCommand(removeCmds, 'Cut ${removeCmds.length} Events', []));
2332-
case [FlxKey.V, true, false, false, _] if (hasClipboardEvent): // ctrl + v -> paste at playhead
2332+
case [FlxKey.V, true, false, false, _] if (hasClipboardEvent && !timeline.layerPanel.isEditing): // ctrl + v -> paste at playhead
23332333
var pasteMs = Conductor.instance.songPosition;
23342334

23352335
if (pasteMs < 0) pasteMs = 0;

source/funkin/ui/haxeui/components/editors/timeline/TimelineLayerPanel.hx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package funkin.ui.haxeui.components.editors.timeline;
22

33
#if FEATURE_CAMERA_EDITOR
44
import funkin.ui.haxeui.components.IconButton;
5+
import funkin.util.ClipboardUtil;
56
import haxe.ui.components.TextField;
67
import haxe.ui.containers.Box;
78
import haxe.ui.containers.HBox;
@@ -41,6 +42,14 @@ class TimelineLayerPanel extends VBox
4142
var _editingLayer:TimelineLayerData = null;
4243
var _editingHandles:LayerRowHandles = null;
4344
var _screenMouseDownBound:MouseEvent->Void;
45+
var _savedClipboard:Null<String> = null;
46+
47+
public var isEditing(get, never):Bool;
48+
49+
function get_isEditing():Bool
50+
{
51+
return _editingLayer != null;
52+
}
4453

4554
public function setScrollOffset(offsetPx:Float):Void
4655
{
@@ -77,6 +86,24 @@ class TimelineLayerPanel extends VBox
7786
_editingHandles.cancelling = false;
7887
_editingHandles = null;
7988
_editingLayer = null;
89+
_restoreSavedClipboard();
90+
}
91+
92+
function _stashClipboardIfSongData():Void
93+
{
94+
var clip:String = ClipboardUtil.getClipboard();
95+
if (clip != null && _looksLikeSongClipboard(clip))
96+
{
97+
_savedClipboard = clip;
98+
ClipboardUtil.setClipboard('');
99+
}
100+
}
101+
102+
function _restoreSavedClipboard():Void
103+
{
104+
if (_savedClipboard == null) return;
105+
if (ClipboardUtil.getClipboard() == '') ClipboardUtil.setClipboard(_savedClipboard);
106+
_savedClipboard = null;
80107
}
81108

82109
public function insertLayerRow(layer:TimelineLayerData, index:Int):Void
@@ -221,6 +248,8 @@ class TimelineLayerPanel extends VBox
221248
handles.field.disabled = false;
222249
handles.field.focus = true;
223250

251+
_stashClipboardIfSongData();
252+
224253
_screenMouseDownBound = _onScreenMouseDown;
225254
Screen.instance.registerEvent(MouseEvent.MOUSE_DOWN, _screenMouseDownBound);
226255
}
@@ -309,6 +338,7 @@ class TimelineLayerPanel extends VBox
309338
handles.editOriginal = null;
310339
_editingLayer = null;
311340
_editingHandles = null;
341+
_restoreSavedClipboard();
312342

313343
if (handles.cancelling)
314344
{
@@ -342,6 +372,14 @@ class TimelineLayerPanel extends VBox
342372
ev.bubble = true;
343373
dispatch(ev);
344374
}
375+
376+
static function _looksLikeSongClipboard(text:String):Bool
377+
{
378+
var trimmed:String = StringTools.trim(text);
379+
return trimmed.length > 0
380+
&& trimmed.charAt(0) == '{'
381+
&& (trimmed.indexOf('"events"') != -1 || trimmed.indexOf('"notes"') != -1);
382+
}
345383
}
346384

347385
@:dox(hide) @:noCompletion

0 commit comments

Comments
 (0)