Skip to content

Commit 974f80b

Browse files
committed
Allow dragging mouse over buttons in main window
1 parent a0cecb8 commit 974f80b

File tree

8 files changed

+55
-6
lines changed

8 files changed

+55
-6
lines changed

packages/webamp/js/components/ClickedDiv.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function ClickedDiv(props: Props) {
2626
{...props}
2727
className={classnames(props.className, { clicked })}
2828
onPointerDown={handlePointerDown}
29+
requireClicksOriginateLocally={false}
2930
/>
3031
);
3132
}

packages/webamp/js/components/MainWindow/ActionButtons.tsx

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,36 @@ const ActionButtons = memo(() => {
1111
const stop = useActionCreator(Actions.stop);
1212
return (
1313
<div className="actions">
14-
<WinampButton id="previous" onClick={previous} title="Previous Track" />
15-
<WinampButton id="play" onClick={play} title="Play" />
16-
<WinampButton id="pause" onClick={pause} title="Pause" />
17-
<WinampButton id="stop" onClick={stop} title="Stop" />
18-
<WinampButton id="next" onClick={next} title="Next Track" />
14+
<WinampButton
15+
id="previous"
16+
onClick={previous}
17+
title="Previous Track"
18+
requireClicksOriginateLocally={false}
19+
/>
20+
<WinampButton
21+
id="play"
22+
onClick={play}
23+
title="Play"
24+
requireClicksOriginateLocally={false}
25+
/>
26+
<WinampButton
27+
id="pause"
28+
onClick={pause}
29+
title="Pause"
30+
requireClicksOriginateLocally={false}
31+
/>
32+
<WinampButton
33+
id="stop"
34+
onClick={stop}
35+
title="Stop"
36+
requireClicksOriginateLocally={false}
37+
/>
38+
<WinampButton
39+
id="next"
40+
onClick={next}
41+
title="Next Track"
42+
requireClicksOriginateLocally={false}
43+
/>
1944
</div>
2045
);
2146
});

packages/webamp/js/components/MainWindow/Eject.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const Eject = memo(() => {
1111
id="eject"
1212
onClick={openMediaFileDialog}
1313
title="Open File(s)"
14+
requireClicksOriginateLocally={false}
1415
/>
1516
);
1617
});

packages/webamp/js/components/MainWindow/EqToggleButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const EqToggleButton = memo(() => {
1919
className={classnames({ selected: windowOpen })}
2020
onClick={handleClick}
2121
title="Toggle Graphical Equalizer"
22+
requireClicksOriginateLocally={false}
2223
/>
2324
);
2425
});

packages/webamp/js/components/MainWindow/PlaylistToggleButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const PlaylistToggleButton = memo(() => {
1919
className={classnames({ selected })}
2020
onClick={handleClick}
2121
title="Toggle Playlist Editor"
22+
requireClicksOriginateLocally={false}
2223
/>
2324
);
2425
});

packages/webamp/js/components/MainWindow/Repeat.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const Repeat = memo(() => {
2626
className={classnames({ selected: repeat })}
2727
onClick={handleClick}
2828
title="Toggle Repeat"
29+
requireClicksOriginateLocally={false}
2930
/>
3031
</ContextMenuWraper>
3132
);

packages/webamp/js/components/MainWindow/Shuffle.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const Shuffle = memo(() => {
2626
className={classnames({ selected: shuffle })}
2727
onClick={handleClick}
2828
title="Toggle Shuffle"
29+
requireClicksOriginateLocally={false}
2930
/>
3031
</ContextMenuWraper>
3132
);

packages/webamp/js/components/WinampButton.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Props = DetailedHTMLPropsAndMore;
2020
/**
2121
* Renders a `div` with an `.winamp-active` class if the element is being clicked/tapped.
2222
*
23-
* For now this mimicks the behavior of `:active`, but in the future we will use
23+
* For now this mimics the behavior of `:active`, but in the future we will use
2424
* this component to mimic Winamp's behavior, which is quite different than
2525
* `:active`.
2626
*
@@ -35,6 +35,7 @@ type Props = DetailedHTMLPropsAndMore;
3535
export default function WinampButton({
3636
requireClicksOriginateLocally = true,
3737
onPointerDown: originalOnPointerDown,
38+
onClick: originalOnClick,
3839
className,
3940
...htmlProps
4041
}: Props): JSX.Element {
@@ -87,6 +88,12 @@ export default function WinampButton({
8788
}
8889
};
8990

91+
const onPointerLeave = (e: React.PointerEvent<HTMLDivElement>) => {
92+
if (e.buttons === 1) {
93+
setActive(false);
94+
}
95+
};
96+
9097
return (
9198
<div
9299
{...htmlProps}
@@ -95,6 +102,17 @@ export default function WinampButton({
95102
onPointerEnter={
96103
requireClicksOriginateLocally ? undefined : onPointerEnter
97104
}
105+
onMouseUp={(e) => {
106+
if (originalOnClick != null) {
107+
originalOnClick(e);
108+
}
109+
if (htmlProps.onMouseUp != null) {
110+
htmlProps.onMouseUp(e);
111+
}
112+
}}
113+
onPointerLeave={
114+
requireClicksOriginateLocally ? undefined : onPointerLeave
115+
}
98116
/>
99117
);
100118
}

0 commit comments

Comments
 (0)