Skip to content

Commit ca76f00

Browse files
committed
Implement the new working fix
1 parent 75bb85d commit ca76f00

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

js/piemenus.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,37 @@ const enableWheelScroll = (wheel, itemCount) => {
163163
wheelDiv.addEventListener("wheel", scrollHandler, { passive: false });
164164
};
165165

166+
// Ensure exit wheels behave like stateless buttons (no sticky selection)
167+
const configureExitWheel = exitWheel => {
168+
if (!exitWheel || !exitWheel.navItems) {
169+
return;
170+
}
171+
172+
const clearSelection = () => {
173+
exitWheel.selectedNavItemIndex = null;
174+
for (let i = 0; i < exitWheel.navItems.length; i++) {
175+
exitWheel.navItems[i].selected = false;
176+
exitWheel.navItems[i].hovered = false;
177+
}
178+
if (exitWheel.raphael && exitWheel.raphael.canvas) {
179+
exitWheel.refreshWheel(true);
180+
}
181+
};
182+
183+
clearSelection();
184+
185+
exitWheel.navigateWheel = clicked => {
186+
const item = exitWheel.navItems[clicked];
187+
if (!item || item.enabled === false) {
188+
return;
189+
}
190+
clearSelection();
191+
if (typeof item.navigateFunction === "function") {
192+
item.navigateFunction();
193+
}
194+
};
195+
};
196+
166197
const piemenuPitches = (block, noteLabels, noteValues, accidentals, note, accidental, custom) => {
167198
let prevPitch = null;
168199
// wheelNav pie menu for pitch selection
@@ -247,6 +278,7 @@ const piemenuPitches = (block, noteLabels, noteValues, accidentals, note, accide
247278
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
248279
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
249280
block._exitWheel.createWheel();
281+
configureExitWheel(block._exitWheel);
250282

251283
if (!custom) {
252284
block._accidentalsWheel.colors = platformColor.accidentalsWheelcolors;
@@ -1000,6 +1032,10 @@ const piemenuCustomNotes = (block, noteLabels, customLabels, selectedCustom, sel
10001032
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
10011033
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
10021034
block._exitWheel.createWheel();
1035+
configureExitWheel(block._exitWheel);
1036+
1037+
1038+
// Avoid auto-selecting the close button on open.
10031039

10041040
const that = block;
10051041

@@ -1231,6 +1267,7 @@ const piemenuNthModalPitch = (block, noteValues, note) => {
12311267
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
12321268
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
12331269
block._exitWheel.createWheel();
1270+
configureExitWheel(block._exitWheel);
12341271

12351272
block._octavesWheel.colors = platformColor.octavesWheelcolors;
12361273
block._octavesWheel.slicePathFunction = slicePath().DonutSlice;
@@ -1480,6 +1517,7 @@ const piemenuAccidentals = (block, accidentalLabels, accidentalValues, accidenta
14801517
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
14811518
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
14821519
block._exitWheel.createWheel();
1520+
configureExitWheel(block._exitWheel);
14831521

14841522
const that = block;
14851523

@@ -1639,6 +1677,7 @@ const piemenuNoteValue = (block, noteValue) => {
16391677
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
16401678
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
16411679
block._exitWheel.createWheel();
1680+
configureExitWheel(block._exitWheel);
16421681

16431682
const tabsLabels = [];
16441683
for (let i = 0; i < WHEELVALUES.length; i++) {
@@ -1899,6 +1938,7 @@ const piemenuNumber = (block, wheelValues, selectedValue) => {
18991938
block._exitWheel.navItems[2].titleSelectedAttr.cursor = "pointer";
19001939
block._exitWheel.navItems[2].titleHoverAttr.cursor = "pointer";
19011940
block._exitWheel.createWheel();
1941+
configureExitWheel(block._exitWheel);
19021942

19031943
const that = block;
19041944

@@ -2179,6 +2219,7 @@ const piemenuColor = (block, wheelValues, selectedValue, mode) => {
21792219
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
21802220
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
21812221
block._exitWheel.createWheel();
2222+
configureExitWheel(block._exitWheel);
21822223

21832224
const that = block;
21842225

@@ -2336,6 +2377,7 @@ const piemenuBasic = (block, menuLabels, menuValues, selectedValue, colors) => {
23362377
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
23372378
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
23382379
block._exitWheel.createWheel();
2380+
configureExitWheel(block._exitWheel);
23392381

23402382
const that = block;
23412383

@@ -2575,6 +2617,7 @@ const piemenuChords = (block, selectedChord) => {
25752617
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
25762618
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
25772619
block._exitWheel.createWheel();
2620+
configureExitWheel(block._exitWheel);
25782621

25792622
const that = block;
25802623

@@ -2719,6 +2762,7 @@ const piemenuVoices = (block, voiceLabels, voiceValues, categories, voice, rotat
27192762
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
27202763
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
27212764
block._exitWheel.createWheel();
2765+
configureExitWheel(block._exitWheel);
27222766

27232767
const that = block;
27242768

@@ -2908,6 +2952,7 @@ const piemenuIntervals = (block, selectedInterval) => {
29082952
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
29092953
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
29102954
block._exitWheel.createWheel();
2955+
configureExitWheel(block._exitWheel);
29112956

29122957
const that = block;
29132958

@@ -3141,6 +3186,7 @@ const piemenuModes = (block, selectedMode) => {
31413186
block._exitWheel.navItems[1].titleSelectedAttr.cursor = "pointer";
31423187
block._exitWheel.navItems[1].titleHoverAttr.cursor = "pointer";
31433188
block._exitWheel.createWheel();
3189+
configureExitWheel(block._exitWheel);
31443190

31453191
const that = block;
31463192

@@ -3759,6 +3805,7 @@ const piemenuGrid = activity => {
37593805
activity.turtles._exitWheel.sliceInitPathCustom = activity.turtles._exitWheel.slicePathCustom;
37603806
activity.turtles._exitWheel.clickModeRotate = false;
37613807
activity.turtles._exitWheel.createWheel(["×", " "]);
3808+
configureExitWheel(activity.turtles._exitWheel);
37623809

37633810
activity.turtles._exitWheel.navItems[0].navigateFunction = () => {
37643811
hidePiemenu(activity);
@@ -3869,6 +3916,7 @@ const piemenuKey = activity => {
38693916
exitWheel.colors = platformColor.exitWheelcolors;
38703917
exitWheel.animatetime = 0;
38713918
exitWheel.createWheel(["×", " "]);
3919+
configureExitWheel(exitWheel);
38723920

38733921
const x = event.clientX;
38743922
const y = event.clientY;
@@ -4190,6 +4238,7 @@ const piemenuDissectNumber = widget => {
41904238
exitWheel.navItems[2].titleSelectedAttr.cursor = "pointer";
41914239
exitWheel.navItems[2].titleHoverAttr.cursor = "pointer";
41924240
exitWheel.createWheel();
4241+
configureExitWheel(exitWheel);
41934242

41944243
// Handle selection
41954244
const __selectionChanged = () => {

0 commit comments

Comments
 (0)