Skip to content
This repository has been archived by the owner on Feb 1, 2025. It is now read-only.

Commit

Permalink
Fixed pasting, and added copying in UITextBox (CodenameCrew#486)
Browse files Browse the repository at this point in the history
KeyModifier somehow returned an int outside of the KeyModifier's range 😭

Apparently there is a boolean that just checks for you called `ctrlKey`.........
  • Loading branch information
ItsLJcool authored Dec 11, 2024
1 parent ed56ec9 commit c4abac4
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions source/funkin/editors/ui/UITextBox.hx
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,21 @@ class UITextBox extends UISliceSprite implements IUIFocusable {
case END:
position = label.text.length;
case V:
if (modifier == KeyModifier.LEFT_CTRL || modifier == KeyModifier.RIGHT_CTRL) {
// paste
var data:String = Clipboard.generalClipboard.getData(TEXT_FORMAT);
if (data != null)
onTextInput(data);
}
// Hey lj here, fixed copying because before we checked if the modifier was left or right ctrl
// but somehow it gave a int outside of the KeyModifier's range :sob:
// apparently there is a boolean that just checks for you. yw :D

// if we are not holding ctrl, ignore
if (!modifier.ctrlKey) return;
// we pasting
var data:String = Clipboard.generalClipboard.getData(TEXT_FORMAT);
if (data != null) onTextInput(data);
case C:
// if we are not holding ctrl, ignore
if (!modifier.ctrlKey) return;

// copying
Clipboard.generalClipboard.setData(TEXT_FORMAT, label.text);
default:
// nothing
}
Expand Down

0 comments on commit c4abac4

Please sign in to comment.