Browse Source

Create rountangle on right-click (instead of alt + left-click)

Jakob Pietron 2 years ago
parent
commit
60a22ebb88

+ 2 - 2
src/frontend/demo_editor.tsx

@@ -18,7 +18,7 @@ export const demo_Editor_description =
         <Text>
         <Text>
             Next to this text you can see three columns <strong>Rountangle Editor</strong>, <strong>Deltas</strong>,
             Next to this text you can see three columns <strong>Rountangle Editor</strong>, <strong>Deltas</strong>,
             and <strong>State Graph</strong>. In the Rountangle Editor, you can create (unnamed) rountangles by
             and <strong>State Graph</strong>. In the Rountangle Editor, you can create (unnamed) rountangles by
-            left-clicking on the grey area with the alt-key pressed (see also the small info in the upper right corner
+            right-clicking on the grey area (see also the small info in the upper right corner
             of each canvas). You can move these rountangle around and resize them.
             of each canvas). You can move these rountangle around and resize them.
         </Text>
         </Text>
         <Text>
         <Text>
@@ -31,7 +31,7 @@ export const demo_Editor_description =
         </Text>
         </Text>
         <Image src={editor}/>
         <Image src={editor}/>
         <Actionblock>
         <Actionblock>
-            1. Create a rountangle!
+            1. Create a rountangle by right-clicking the grey area in the left column!
         </Actionblock>
         </Actionblock>
         <Resultblock>
         <Resultblock>
             In the center column, one composite delta (or L1 delta) "createRountangle" was created.
             In the center column, one composite delta (or L1 delta) "createRountangle" was created.

+ 10 - 5
src/frontend/rountangleEditor/RountangleEditor.tsx

@@ -163,13 +163,12 @@ export class RountangleEditor extends React.Component<RountangleEditorProps, Rou
     }
     }
 
 
     onPointerDown = (event: React.PointerEvent<SVGSVGElement>) => {
     onPointerDown = (event: React.PointerEvent<SVGSVGElement>) => {
-        // only left mouse button
-        if (event.button !== 0) return;
         event.stopPropagation();
         event.stopPropagation();
         event.preventDefault();
         event.preventDefault();
-        event.currentTarget.setPointerCapture(event.pointerId);
 
 
-        if (!event.altKey) {
+        // only left mouse button
+        if (event.button === 0) {
+            event.currentTarget.setPointerCapture(event.pointerId);
             this.setState({dragging: true, moved: false});
             this.setState({dragging: true, moved: false});
         }
         }
     }
     }
@@ -200,6 +199,11 @@ export class RountangleEditor extends React.Component<RountangleEditorProps, Rou
         return refPoint.matrixTransform(screenCTM.inverse());
         return refPoint.matrixTransform(screenCTM.inverse());
     }
     }
 
 
+    onContextMenu = (event: React.PointerEvent<SVGSVGElement>) => {
+        event.stopPropagation();
+        event.preventDefault();
+    }
+
     onPointerUp = (event: React.PointerEvent<SVGSVGElement>) => {
     onPointerUp = (event: React.PointerEvent<SVGSVGElement>) => {
         event.stopPropagation();
         event.stopPropagation();
         event.preventDefault();
         event.preventDefault();
@@ -211,7 +215,7 @@ export class RountangleEditor extends React.Component<RountangleEditorProps, Rou
         });
         });
 
 
         // add new state on left mouse button and ALT-Key pressed
         // add new state on left mouse button and ALT-Key pressed
-        if (event.button === 0 && event.altKey) {
+        if (event.button === 2) {
             const cursorPoint = this.clickToSVGPos(event.clientX, event.clientY);
             const cursorPoint = this.clickToSVGPos(event.clientX, event.clientY);
 
 
             if (cursorPoint) {
             if (cursorPoint) {
@@ -252,6 +256,7 @@ export class RountangleEditor extends React.Component<RountangleEditorProps, Rou
                    onPointerDown={this.onPointerDown}
                    onPointerDown={this.onPointerDown}
                    onPointerMove={this.onPointerMove}
                    onPointerMove={this.onPointerMove}
                    onPointerUp={this.onPointerUp}
                    onPointerUp={this.onPointerUp}
+                   onContextMenu={this.onContextMenu}
                    width='350px'
                    width='350px'
                    height='100%'
                    height='100%'
                    viewBox={`${this.state.translateX} ${this.state.translateY} ${this.state.currentWidth} ${this.state.currentHeight}`}
                    viewBox={`${this.state.translateX} ${this.state.translateY} ${this.state.currentWidth} ${this.state.currentHeight}`}

+ 2 - 1
src/frontend/versioned_model.tsx

@@ -73,7 +73,8 @@ const helpText = {
   rountangleEditor: <>
   rountangleEditor: <>
     <Mantine.Divider label="Controls" labelPosition="center"/>
     <Mantine.Divider label="Controls" labelPosition="center"/>
     <Mantine.Text>
     <Mantine.Text>
-      <b>Alt + Left-Click</b>: Create/Delete Rountangle<br/>
+      <b>Right-Click</b>: Create Rountangle<br/>
+      <b>Alt + Left-Click</b>: Delete Rountangle<br/>
       <b>Left-Drag</b>: Move/Resize Rountangle / Pan Canvas<br/>
       <b>Left-Drag</b>: Move/Resize Rountangle / Pan Canvas<br/>
       <b>Wheel</b>: Zoom<br/>
       <b>Wheel</b>: Zoom<br/>
     </Mantine.Text>
     </Mantine.Text>