Skip to content

Commit b971d6c

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

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

js/piemenus.js

Lines changed: 48 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,9 @@ 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+
// Avoid auto-selecting the close button on open.
10031038

10041039
const that = block;
10051040

@@ -1231,6 +1266,7 @@ const piemenuNthModalPitch = (block, noteValues, note) => {
12311266
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
12321267
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
12331268
block._exitWheel.createWheel();
1269+
configureExitWheel(block._exitWheel);
12341270

12351271
block._octavesWheel.colors = platformColor.octavesWheelcolors;
12361272
block._octavesWheel.slicePathFunction = slicePath().DonutSlice;
@@ -1480,6 +1516,7 @@ const piemenuAccidentals = (block, accidentalLabels, accidentalValues, accidenta
14801516
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
14811517
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
14821518
block._exitWheel.createWheel();
1519+
configureExitWheel(block._exitWheel);
14831520

14841521
const that = block;
14851522

@@ -1639,6 +1676,7 @@ const piemenuNoteValue = (block, noteValue) => {
16391676
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
16401677
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
16411678
block._exitWheel.createWheel();
1679+
configureExitWheel(block._exitWheel);
16421680

16431681
const tabsLabels = [];
16441682
for (let i = 0; i < WHEELVALUES.length; i++) {
@@ -1899,6 +1937,7 @@ const piemenuNumber = (block, wheelValues, selectedValue) => {
18991937
block._exitWheel.navItems[2].titleSelectedAttr.cursor = "pointer";
19001938
block._exitWheel.navItems[2].titleHoverAttr.cursor = "pointer";
19011939
block._exitWheel.createWheel();
1940+
configureExitWheel(block._exitWheel);
19021941

19031942
const that = block;
19041943

@@ -2179,6 +2218,7 @@ const piemenuColor = (block, wheelValues, selectedValue, mode) => {
21792218
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
21802219
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
21812220
block._exitWheel.createWheel();
2221+
configureExitWheel(block._exitWheel);
21822222

21832223
const that = block;
21842224

@@ -2336,6 +2376,7 @@ const piemenuBasic = (block, menuLabels, menuValues, selectedValue, colors) => {
23362376
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
23372377
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
23382378
block._exitWheel.createWheel();
2379+
configureExitWheel(block._exitWheel);
23392380

23402381
const that = block;
23412382

@@ -2575,6 +2616,7 @@ const piemenuChords = (block, selectedChord) => {
25752616
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
25762617
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
25772618
block._exitWheel.createWheel();
2619+
configureExitWheel(block._exitWheel);
25782620

25792621
const that = block;
25802622

@@ -2719,6 +2761,7 @@ const piemenuVoices = (block, voiceLabels, voiceValues, categories, voice, rotat
27192761
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
27202762
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
27212763
block._exitWheel.createWheel();
2764+
configureExitWheel(block._exitWheel);
27222765

27232766
const that = block;
27242767

@@ -2908,6 +2951,7 @@ const piemenuIntervals = (block, selectedInterval) => {
29082951
block._exitWheel.navItems[0].titleSelectedAttr.cursor = "pointer";
29092952
block._exitWheel.navItems[0].titleHoverAttr.cursor = "pointer";
29102953
block._exitWheel.createWheel();
2954+
configureExitWheel(block._exitWheel);
29112955

29122956
const that = block;
29132957

@@ -3141,6 +3185,7 @@ const piemenuModes = (block, selectedMode) => {
31413185
block._exitWheel.navItems[1].titleSelectedAttr.cursor = "pointer";
31423186
block._exitWheel.navItems[1].titleHoverAttr.cursor = "pointer";
31433187
block._exitWheel.createWheel();
3188+
configureExitWheel(block._exitWheel);
31443189

31453190
const that = block;
31463191

@@ -3759,6 +3804,7 @@ const piemenuGrid = activity => {
37593804
activity.turtles._exitWheel.sliceInitPathCustom = activity.turtles._exitWheel.slicePathCustom;
37603805
activity.turtles._exitWheel.clickModeRotate = false;
37613806
activity.turtles._exitWheel.createWheel(["×", " "]);
3807+
configureExitWheel(activity.turtles._exitWheel);
37623808

37633809
activity.turtles._exitWheel.navItems[0].navigateFunction = () => {
37643810
hidePiemenu(activity);
@@ -3869,6 +3915,7 @@ const piemenuKey = activity => {
38693915
exitWheel.colors = platformColor.exitWheelcolors;
38703916
exitWheel.animatetime = 0;
38713917
exitWheel.createWheel(["×", " "]);
3918+
configureExitWheel(exitWheel);
38723919

38733920
const x = event.clientX;
38743921
const y = event.clientY;
@@ -4190,6 +4237,7 @@ const piemenuDissectNumber = widget => {
41904237
exitWheel.navItems[2].titleSelectedAttr.cursor = "pointer";
41914238
exitWheel.navItems[2].titleHoverAttr.cursor = "pointer";
41924239
exitWheel.createWheel();
4240+
configureExitWheel(exitWheel);
41934241

41944242
// Handle selection
41954243
const __selectionChanged = () => {

0 commit comments

Comments
 (0)