nixos-configs/config/ags/js/misc/cursorbox.js

35 lines
927 B
JavaScript
Raw Permalink Normal View History

2023-09-04 22:27:34 -04:00
import Gdk from 'gi://Gdk';
const display = Gdk.Display.get_default();
2023-09-11 19:28:22 -04:00
export const EventBox = ({ reset = true, ...params }) => ags.Widget.EventBox({
2023-09-04 22:27:34 -04:00
...params,
onHover: box => {
if (! box.child.sensitive || ! box.sensitive) {
box.window.set_cursor(Gdk.Cursor.new_from_name(display, 'not-allowed'));
}
else {
box.window.set_cursor(Gdk.Cursor.new_from_name(display, 'pointer'));
}
2023-09-04 22:27:34 -04:00
},
onHoverLost: box => {
2023-09-11 19:28:22 -04:00
if (reset)
box.window.set_cursor(null);
2023-09-04 22:27:34 -04:00
},
});
export const Button = ({ reset = true, ...params }) => ags.Widget.Button({
...params,
onHover: box => {
if (! box.child.sensitive || ! box.sensitive) {
box.window.set_cursor(Gdk.Cursor.new_from_name(display, 'not-allowed'));
}
else {
box.window.set_cursor(Gdk.Cursor.new_from_name(display, 'pointer'));
}
},
onHoverLost: box => {
if (reset)
box.window.set_cursor(null);
},
});