WIP: Copy paste is almost done

This commit is contained in:
MatCat 2021-03-13 20:15:45 -08:00
parent 187664e36a
commit 7d0807d30c
5 changed files with 54 additions and 11 deletions

View File

@ -52,9 +52,9 @@
<li id="tfm_Undo" value="EditUndo" class="disabled" title="Feature coming soon">Undo</li> <li id="tfm_Undo" value="EditUndo" class="disabled" title="Feature coming soon">Undo</li>
<li id="tfm_Redo" value="EditRedo" class="disabled" title="Feature coming soon">Redo</li> <li id="tfm_Redo" value="EditRedo" class="disabled" title="Feature coming soon">Redo</li>
<li class="tfm_seperator"></li> <li class="tfm_seperator"></li>
<li id="tfm_Cut" class="disabled" title="Feature coming soon">Cut</li> <li id="tfm_Cut" value="Cut">Cut</li>
<li id="tfm_Copy" class="disabled" title="Feature coming soon">Copy</li> <li id="tfm_Copy" value="Copy">Copy</li>
<li id="tfm_Paste" class="disabled" title="Feature coming soon">Paste</li> <li id="tfm_Paste" value="Paste">Paste</li>
<li class="tfm_seperator"></li> <li class="tfm_seperator"></li>
<li id="tfm_Delete" value="DeleteElements" class="disabled">Delete</li> <li id="tfm_Delete" value="DeleteElements" class="disabled">Delete</li>
<li id="tfm_Disconnect" value="DisconnectElements" class="disabled">Disconnect</li> <li id="tfm_Disconnect" value="DisconnectElements" class="disabled">Disconnect</li>

View File

@ -51,7 +51,7 @@ class LogicNAND extends LogicAND {
constructor(_Container, RestoreData = null, logicengine,Inputs) { constructor(_Container, RestoreData = null, logicengine,Inputs) {
super(_Container, RestoreData,logicengine,Inputs); super(_Container, RestoreData,logicengine,Inputs);
this.Name = "NAND"; this.Name = "NAND";
this.Width = this.Width + 10; this.Width = 110;
} }
getOutput(Output=0) { getOutput(Output=0) {
@ -162,7 +162,7 @@ class LogicNOR extends LogicOR {
constructor(_Container, RestoreData = null, logicengine,Inputs) { constructor(_Container, RestoreData = null, logicengine,Inputs) {
super(_Container, RestoreData,logicengine,Inputs); super(_Container, RestoreData,logicengine,Inputs);
this.Name = "NOR"; this.Name = "NOR";
this.Width = this.Width + 10; this.Width = 110;
} }
getOutput(Output=0) { getOutput(Output=0) {
if (super.getOutput() === 0) return false; if (super.getOutput() === 0) return false;
@ -289,7 +289,7 @@ class LogicXNOR extends Element {
super(_Container, RestoreData,logicengine,2); // Only 2 inputs on XOR super(_Container, RestoreData,logicengine,2); // Only 2 inputs on XOR
this.Name = "XNOR"; this.Name = "XNOR";
this.removeProperty("Inputs"); this.removeProperty("Inputs");
this.Width += 10; this.Width = 110;
} }
getOutput(Output=0) { getOutput(Output=0) {
@ -368,7 +368,7 @@ class LogicNOT extends Element {
super(_Container, RestoreData,logicengine,1); // Only 1 inputs on NOT super(_Container, RestoreData,logicengine,1); // Only 1 inputs on NOT
this.Name = "NOT"; this.Name = "NOT";
this.removeProperty("Inputs"); this.removeProperty("Inputs");
this.Width += 10; this.Width = 110;
} }
getOutput(Output=0) { getOutput(Output=0) {

View File

@ -428,9 +428,7 @@ function loadActiveContainer(Elements) {
logicEngine.MovingElement = new Array(logicEngine.ActiveContainer.Selected.length); logicEngine.MovingElement = new Array(logicEngine.ActiveContainer.Selected.length);
for (let b = 0; b < logicEngine.ActiveContainer.Selected.length; b++) { for (let b = 0; b < logicEngine.ActiveContainer.Selected.length; b++) {
//logicEngine.ActiveContainer.Selected[b].X = (logicEngine.ActiveContainer.Selected[b].X - ((highestX-lowestX)/2)) + logicEngine.Mouse.x;
logicEngine.ActiveContainer.Selected[b].X = (logicEngine.ActiveContainer.Selected[b].X - lowestX) + logicEngine.Mouse.x - ((highestX-lowestX)/2); logicEngine.ActiveContainer.Selected[b].X = (logicEngine.ActiveContainer.Selected[b].X - lowestX) + logicEngine.Mouse.x - ((highestX-lowestX)/2);
//logicEngine.ActiveContainer.Selected[b].Y = (logicEngine.ActiveContainer.Selected[b].Y - ((highestY-lowestY)/2)) + logicEngine.Mouse.y;
logicEngine.ActiveContainer.Selected[b].Y = (logicEngine.ActiveContainer.Selected[b].Y - lowestY) + logicEngine.Mouse.y - ((highestY-lowestY)/2); logicEngine.ActiveContainer.Selected[b].Y = (logicEngine.ActiveContainer.Selected[b].Y - lowestY) + logicEngine.Mouse.y - ((highestY-lowestY)/2);
logicEngine.MovingElement[b] = { logicEngine.MovingElement[b] = {
StartX: logicEngine.ActiveContainer.Selected[b].X, StartX: logicEngine.ActiveContainer.Selected[b].X,

View File

@ -162,8 +162,31 @@ class LogicEngineSettings {
Meta: false, Meta: false,
Name: "Help Window", Name: "Help Window",
Description: "Opens help window", Description: "Opens help window",
Category: "Other"} Category: "Other"},
Cut: {Key: "x", // lowercase
Alt: false,
Shift: false,
Ctrl: true,
Meta: false,
Name: "Cut",
Description: "Cuts selected elements to clipboard",
Category: "Invisible"},
Copy: {Key: "c", // lowercase
Alt: false,
Shift: false,
Ctrl: true,
Meta: false,
Name: "Copy",
Description: "Copy selected elements to clipboard",
Category: "Invisible"},
Paste: {Key: "v", // lowercase
Alt: false,
Shift: false,
Ctrl: true,
Meta: false,
Name: "Paste",
Description: "pastes selected elements from clipboard",
Category: "Invisible"}
/* /*
keybind_name: {Key: "", // lowercase keybind_name: {Key: "", // lowercase

View File

@ -176,6 +176,28 @@ rcm_Delete.addEventListener('click', function(evt) {
disableSelectedRCMs(true); disableSelectedRCMs(true);
}); });
let tfm_Cut = document.getElementById("tfm_Cut");
tfm_Cut.addEventListener('click', function(evt) {
document.execCommand('cut');
disableSelectedRCMs(true);
setTimeout(function(){hideMenus()},10);
});
let tfm_Copy = document.getElementById("tfm_Copy");
tfm_Copy.addEventListener('click', function(evt) {
document.execCommand('copy');
disableSelectedRCMs(true);
setTimeout(function(){hideMenus()},10);
});
let tfm_Paste = document.getElementById("tfm_Paste");
tfm_Paste.addEventListener('click', function(evt) {
document.execCommand('paste');
disableSelectedRCMs(true);
setTimeout(function(){hideMenus()},10);
});
let tfm_Delete = document.getElementById("tfm_Delete"); let tfm_Delete = document.getElementById("tfm_Delete");
tfm_Delete.addEventListener('click', function(evt) { tfm_Delete.addEventListener('click', function(evt) {
logicEngine.Key_Press({ctrlKey: false, key: "Delete"}); logicEngine.Key_Press({ctrlKey: false, key: "Delete"});