chrstphrchvz / perl-tcl-ptk

Tcl::pTk - Interface to Tcl/Tk with Perl/Tk compatible syntax
https://metacpan.org/pod/Tcl::pTk
Other
8 stars 2 forks source link

macOS aqua: BrowseEntry dropdown appears behind window #15

Open chrstphrchvz opened 3 years ago

chrstphrchvz commented 3 years ago

https://rt.cpan.org/Ticket/Display.html?id=127772#txn-1821064

Using aqua Tk 8.6.9.1 on macOS 10.14.1, the dropdown list/popup for BrowseEntry widgets appears behind the window rather than in front of it. (I don't remember ever trying this on Tk 8.6.8 or earlier.) See attached screenshot.

Some workarounds would be to use ComboBox or ttkBrowseEntry instead, although I am not completely aware of how they differ from BrowseEntry. Without having investigated this much, I'm not sure BrowseEntry can be completely replaced by either of those in a Perl/Tk compatible manner. For example, existing code might depend on BrowseEntry's discrete listbox or button widgets. It would be simpler if BrowseEntry wasn't something to separately maintain, though.

image

chrstphrchvz commented 3 years ago

https://rt.cpan.org/Ticket/Display.html?id=127772#txn-1890228

There is a documented limitation in the behavior of grab on Tk Aqua where only the grab window can be focused and receive mouse and key events.

A Tcl script that exhibits the limitation (careful when running this on X11):

pack [ttk::button .b -text {Popup overlay}]

toplevel .t -background green
wm overrideredirect .t 1
wm withdraw .t

.b configure -command {
    wm deiconify .t
    wm geometry .t [wm geometry .]
    raise .t

    # On Aqua, this raises . and
    # doesn't allow interacting with .t
    grab -global .
}

Maybe BrowseEntry can be revised to act more like ttk::combobox, which uses slightly different approaches for each platform (see combobox.tcl in Tk).

chrstphrchvz commented 3 years ago

Maybe BrowseEntry can be revised to act more like ttk::combobox, which uses slightly different approaches for each platform (see combobox.tcl in Tk).

So far I have not been successful at adapting the approach in combobox.tcl. And because of the platform inconsistencies evident in combobox.tcl, I'm not sure I could convince upstream Tcl/Tk that there is an inconsistency they can or should address that would resolve this issue.