Skip to content

Commit b0df1da

Browse files
committed
fix right click menu example
1 parent 6163fa7 commit b0df1da

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/content/docs/config/widgets.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -393,17 +393,21 @@ subclass of [Gtk.Menu](https://gjs-docs.gnome.org/gtk30~3.0/gtk.menu)
393393
| on-move-scroll | `(scroll_type: Gtk.ScrollType) => void` |
394394

395395
```js
396-
// to have a menu popup on click
397-
const button = Widget.Button({
398-
child: Widget.Label('click to open menu'),
399-
onPrimaryClick: (_, event) => Widget.Menu({
396+
function RightClickMenu() {
397+
const menu = Widget.Menu({
400398
children: [
401399
Widget.MenuItem({
402400
child: Widget.Label('hello'),
403401
}),
404402
],
405-
}).popup_at_pointer(event),
406-
})
403+
})
404+
405+
return Widget.Button({
406+
on_primary_click: (_, event) => {
407+
menu.popup_at_pointer(event)
408+
},
409+
})
410+
}
407411
```
408412

409413
### MenuItem

0 commit comments

Comments
 (0)