This commit is contained in:
team3
2026-09-19 22:50:49 +02:00
parent 9bb3a30783
commit e0c615c73a
9 changed files with 98 additions and 92 deletions

View File

@@ -12,7 +12,7 @@ export function button(label, onClick, styleClass = 'desktop-button') {
return b;
}
// Button mit linksbündigem, gekürztem Text und optionalem Icon. onClick(button, mausTaste): 1 = links, 3 = rechts.
// Button mit linksbündigem, gekürztem Text und optionalem Icon. onClick(button, mausTaste): 1 = links, 2 = Mitte, 3 = rechts.
export function textButton(text, onClick, styleClass, iconName = null) {
const label = new St.Label({text, x_expand: true, x_align: Clutter.ActorAlign.START, y_align: Clutter.ActorAlign.CENTER});
label.clutter_text.ellipsize = Pango.EllipsizeMode.END;
@@ -28,7 +28,7 @@ export function textButton(text, onClick, styleClass, iconName = null) {
can_focus: true,
x_expand: true,
x_align: Clutter.ActorAlign.FILL,
button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
button_mask: St.ButtonMask.ONE | St.ButtonMask.TWO | St.ButtonMask.THREE,
});
b.connect('clicked', onClick);
b.label_actor = label;
@@ -77,13 +77,18 @@ export function multilineEntry(text, styleClass, scrollClass, hint = '') {
return [scroll, entry];
}
// Kleines Fenster neben einem Anker (Actor oder {x, y}). Hält Maus und Tastatur.
// Kleines Fenster am Mauszeiger oder neben einem Anker (Actor oder {x, y}). Hält Maus und Tastatur.
// Enter in einem Feld speichert, Klick daneben oder Esc bricht ab. Keine Buttons.
// Mehrere Popover stapeln sich, das oberste hält den Grab.
// Bei aktivem Grab laufen Events nur durch den Grab-Actor, daher hängt captured-event an der Box.
export class Popover {
// Ohne Anker öffnet das Popover am Mauszeiger.
// below: unter dem Anker statt daneben (für Auswahllisten unter einem Button)
constructor(anchor, styleClass = 'form', {below = false} = {}) {
constructor(anchor = null, styleClass = 'form', {below = false} = {}) {
if (!anchor) {
const [x, y] = global.get_pointer();
anchor = {x, y};
}
this._anchor = anchor;
this._below = below;
this.box = new St.BoxLayout({vertical: true, style_class: `desktop-popover ${styleClass}`, reactive: true});
@@ -214,8 +219,7 @@ export class Popover {
// Kontextmenü am Mauszeiger. items: [{label, onSelect, sensitive = true}]
export function contextMenu(items) {
const [x, y] = global.get_pointer();
const menu = new Popover({x, y}, 'menu');
const menu = new Popover(null, 'menu');
for (const item of items) {
const row = textButton(item.label, () => {
menu.close();