feat(utils): useButtonNavigation now exposes pressed button
This commit is contained in:
@@ -15,6 +15,9 @@ export const useScreen = () => {
|
||||
const registerClick = inject<(cb: ScreenClickCallback) => () => void>(
|
||||
"registerScreenClickCallback",
|
||||
);
|
||||
const registerMouseDown = inject<(cb: ScreenClickCallback) => () => void>(
|
||||
"registerScreenMouseDownCallback",
|
||||
);
|
||||
const registerWheel = inject<(cb: ScreenMouseWheelCallback) => () => void>(
|
||||
"registerScreenMouseWheelCallback",
|
||||
);
|
||||
@@ -37,6 +40,15 @@ export const useScreen = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const onMouseDown = (callback: ScreenClickCallback) => {
|
||||
onMounted(() => {
|
||||
if (!registerMouseDown)
|
||||
throw new Error("useScreen must be used within a Screen component");
|
||||
const unregister = registerMouseDown(callback);
|
||||
onUnmounted(unregister);
|
||||
});
|
||||
};
|
||||
|
||||
const onMouseWheel = (callback: ScreenMouseWheelCallback) => {
|
||||
onMounted(() => {
|
||||
if (!registerWheel)
|
||||
@@ -46,5 +58,5 @@ export const useScreen = () => {
|
||||
});
|
||||
};
|
||||
|
||||
return { onRender, onClick, onMouseWheel };
|
||||
return { onRender, onClick, onMouseDown, onMouseWheel };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user