Aylur / ags

A customizable and extensible shell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Override default key bindings/shortcuts for Entry widget

theoahfeldt opened this issue · comments

When typing inside a Entry widget, pressing Control-a for example selects the entire text in the entry. If I have a box containing a child entry and I want to assign a shortcuts using .keybind(["CONTROL", "a", foo]), foo will not execute when pressing Control-a if the Entry widget is in focus. Instead, we get the default behavior of selecting the entire text. Is it possible to let my binding take priority so that foo always gets executed when pressing Control-a?

the leafs of the widget tree will always take precedence, you need to make the entry let the event bubble up

Widget.Entry({
    setup(self) {
        self.keybind(["CONTROL"], "a", () => {
            return true
        })
    },
})