Skip to content

Commit 87af137

Browse files
committed
Merge branch 'noahFeatureII' into muiv4tov6
2 parents b460f23 + 04e3f20 commit 87af137

File tree

4 files changed

+78
-38
lines changed

4 files changed

+78
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ yarn.lock
44
### Linux ###
55
*~
66

7+
RT.zip
78
# temporary files which can be created if a process still has a handle open of a deleted file
89
.fuse_hidden*
910

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ COPY ../server ./server
5555

5656
# these things build dosent have so dont copy them through
5757
COPY package*.json ./
58-
COPY .env .env
58+
#COPY .env .env
5959
COPY ./config.js ./config.js
6060

6161

app/src/components/ContextMenu.tsx

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ function ContextMenu({
1313
mouseXState,
1414
mouseYState,
1515
selectedItem,
16+
menuTypeState,
17+
selectedItemId,
1618
targetColor,
1719
PanRef
1820
}) {
@@ -31,9 +33,7 @@ function ContextMenu({
3133
//@ts-ignore
3234
const contextParam = useSelector((store: RootState) => store.contextSlice); // this is literally just passed in on everything else, i have no idea what it does, you can look it up, but other files are literally just taking it and passing it back in.
3335

34-
const MenuTypeRef = useRef('?');
35-
36-
let selectedItemId = useRef(-1); // dont trigger rerenders cause this shouldent change.
36+
//let selectedItemId = useRef(-1); // dont trigger rerenders cause this shouldent change.
3737
// attach key listener
3838

3939
// The below is for all key events
@@ -50,34 +50,34 @@ function ContextMenu({
5050
document.addEventListener('keydown', keyStrokeFunction);
5151
}, [openMenu]);
5252

53-
// set the focus on focus change
54-
useEffect(() => {
55-
let thing = selectedItem; // look up th dom to see when we get to an element we like (if you right click on the span element you should still count as clicking the ReactTypeComponent element)
56-
for (let i = 0; i < 5; i++) {
57-
// just things that we want to stop on...
58-
if (!thing.id || !thing.id.match(/canv/)) {
59-
thing = thing.parentElement;
60-
} else {
61-
// once were all said and done...
62-
if (thing.id.match(/^canv[0-9]/)) {
63-
MenuTypeRef.current = 'CanvasElement';
64-
} else {
65-
MenuTypeRef.current = '?'; // set this back to unknown if you click out.
66-
}
53+
// // set the focus on focus change
54+
// useEffect(() => {
55+
// let thing = selectedItem; // look up th dom to see when we get to an element we like (if you right click on the span element you should still count as clicking the ReactTypeComponent element)
56+
// for (let i = 0; i < 5; i++) {
57+
// // just things that we want to stop on...
58+
// if (!thing.id || !thing.id.match(/canv/)) {
59+
// thing = thing.parentElement;
60+
// } else {
61+
// // once were all said and done...
62+
// if (thing.id.match(/^canv[0-9]/)) {
63+
// MenuTypeRef.current = 'CanvasElement';
64+
// } else {
65+
// MenuTypeRef.current = '?'; // set this back to unknown if you click out.
66+
// }
6767

68-
selectedItemId.current = Number(thing.id.split('canv')[1]); // this code tells us what hypothetical reaactType item we are selected, not just which DOM element.
69-
break;
70-
}
71-
}
68+
// selectedItemId.current = Number(thing.id.split('canv')[1]); // this code tells us what hypothetical reaactType item we are selected, not just which DOM element.
69+
// break;
70+
// }
71+
// }
7272

73-
dispatch({
74-
type: 'appState/changeFocus',
75-
payload: {
76-
componentId: appState.canvasFocus.componentId,
77-
childId: selectedItemId.current
78-
}
79-
});
80-
}, [selectedItem]); // re trigger if the position of the context menu changes.
73+
// dispatch({
74+
// type: 'appState/changeFocus',
75+
// payload: {
76+
// componentId: appState.canvasFocus.componentId,
77+
// childId: selectedItemId.current // no more current
78+
// }
79+
// });
80+
// }, [selectedItem]); // re trigger if the position of the context menu changes.
8181

8282
// remove the keystroke listener on unmount.
8383
useEffect(
@@ -99,7 +99,7 @@ function ContextMenu({
9999

100100
let correctChild = searchChildren(
101101
appState.components[0].children,
102-
selectedItemId.current
102+
selectedItemId
103103
); // helper function below
104104

105105
let fullAttributes = correctChild[stateTarget];
@@ -138,7 +138,7 @@ function ContextMenu({
138138

139139
let correctChild = searchChildren(
140140
appState.components[0].children, // this is simply searching for the correct actual component from the dom elemnt ref
141-
selectedItemId.current
141+
selectedItemId
142142
); // helper function below
143143

144144
let displayText = correctChild[stateSlice][innerTarget];
@@ -164,7 +164,7 @@ function ContextMenu({
164164
}}
165165
ref={PanRef}
166166
>
167-
{MenuTypeRef.current === 'CanvasElement' && (
167+
{menuTypeState === 'CanvasElement' && (
168168
<div>
169169
{false && (
170170
<div

app/src/containers/MainContainer.tsx

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ const MainContainer = (props): JSX.Element => {
6262
const [mouseXState, setMouseXState] = useState(0);
6363
const [mouseYState, setMouseYState] = useState(0);
6464

65+
const [menuTypeState, setMenuTypeState] = useState('?');
66+
67+
const [selectedItemIdState, setSelectedItemIdState] = useState(-1);
68+
6569
const [contextMenuSelectedElement, setContextMenuSelectedElement] =
6670
useState(null);
6771
//
@@ -96,18 +100,51 @@ const MainContainer = (props): JSX.Element => {
96100
// use effect for contextMenu listeners
97101
useEffect(() => {
98102
document.addEventListener('contextmenu', (e) => {
99-
e.preventDefault(); // grab that event trigger, or maybe this writes to something, idk
103+
console.log(e.target);
100104
if (
101105
ContextMenuRef.current != null &&
102106
ContextMenuRef.current.contains(e.target)
103107
) {
108+
e.preventDefault(); // grab that event trigger, or maybe this writes to something, idk
104109
return; // if it is not nul and we are clicking in it.
105110
}
106-
setContextMenuSelectedElement(e.target); // get it set it
107111

108-
setMouseXState(MouseXRef.current);
109-
setMouseYState(MouseYRef.current); // now trigger a re-render
110-
setContextMenuOpen(true);
112+
// set the focus on focus change
113+
let willGrabDefault = true;
114+
let thing = e.target; // look up th dom to see when we get to an element we like (if you right click on the span element you should still count as clicking the ReactTypeComponent element)
115+
for (let i = 0; i < 5; i++) {
116+
// just things that we want to stop on...
117+
if (!thing.id || !thing.id.match(/canv/)) {
118+
thing = thing.parentElement;
119+
} else {
120+
// once were all said and done...
121+
if (thing.id.match(/^canv[0-9]/)) {
122+
setMenuTypeState('CanvasElement');
123+
} else {
124+
willGrabDefault = false;
125+
setMenuTypeState('?'); // set this back to unknown if you click out.
126+
}
127+
128+
setSelectedItemIdState(Number(thing.id.split('canv')[1])); // this code tells us what hypothetical reaactType item we are selected, not just which DOM element.
129+
break;
130+
}
131+
}
132+
if (willGrabDefault) {
133+
e.preventDefault(); // gdouble
134+
dispatch({
135+
type: 'appState/changeFocus',
136+
payload: {
137+
componentId: appState.canvasFocus.componentId,
138+
childId: selectedItemIdState
139+
}
140+
});
141+
142+
setContextMenuSelectedElement(e.target); // get it set it
143+
144+
setMouseXState(MouseXRef.current);
145+
setMouseYState(MouseYRef.current); // now trigger a re-render
146+
setContextMenuOpen(true);
147+
}
111148
});
112149
onmousemove = function (e) {
113150
MouseXRef.current = e.clientX; // this is a use ref, not use state, so we dont trigger a re-render.
@@ -207,6 +244,8 @@ const MainContainer = (props): JSX.Element => {
207244
targetColor={contextMenuColor}
208245
PanRef={ContextMenuRef}
209246
visible={contextMenuOpen}
247+
selectedItemId={selectedItemIdState}
248+
menuTypeState={menuTypeState}
210249
setContextMenuOpen={setContextMenuOpen}
211250
mouseXState={mouseXState}
212251
mouseYState={mouseYState}

0 commit comments

Comments
 (0)