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

38 lines
964 B
JavaScript
Raw Normal View History

import { Widget } from '../../imports.js';
2023-09-04 22:27:34 -04:00
import Gdk from 'gi://Gdk';
const display = Gdk.Display.get_default();
export const EventBox = ({ reset = true, ...params }) => 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 }) => 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);
},
});