Skip Menu |

This queue is for tickets about the Tcl-pTk CPAN distribution.

Report information
The Basics
Id: 127120
Status: resolved
Priority: 0/
Queue: Tcl-pTk

People
Owner: CAC [...] cpan.org
Requestors: welleozean [...] googlemail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.95



Subject: [macOS] Right-clic contextual menu
Date: Sun, 16 Sep 2018 13:27:25 +0200
To: bug-Tcl-pTk [...] rt.cpan.org
From: welle Ozean <welleozean [...] googlemail.com>
Hello, Perl 5.28 macOS: HighSierra Tcl: shipped with macOS Tcl::pTk-0.94 I found a strange behavior when right-clicking (I am using the trackpad) on any Widget that has a linked contextual menu (Text, Entry and so on): the menu is shown but at the same it seems to perform a copy and paste operation. Simply try one of the demo widgets (widgetTclpTk->Basic editable text), highlight a word, and right-click on it. The popup is shown and after a while (the time windows seems to vary (?!?)) the highlighted term is copied in the Text Widget. I have already read the following node with what are - I guess - related problems: https://www.perlmonks.org/?node_id=1215349 This problem prevents the use of any right-click features and should be addressed. Any workaround? Best, Welle
On Sun Sep 16 06:27:51 2018, welleozean@googlemail.com wrote:
Show quoted text
> Hello,
>
> Perl 5.28
> macOS: HighSierra
> Tcl: shipped with macOS
> Tcl::pTk-0.94
>
> I found a strange behavior when right-clicking (I am using the trackpad) on
> any Widget that has a linked contextual menu (Text, Entry and so on): the
> menu is shown but at the same it seems to perform a copy and paste
> operation. Simply try one of the demo widgets (widgetTclpTk->Basic editable
> text), highlight a word, and right-click on it. The popup is shown and
> after a while (the time windows seems to vary (?!?)) the highlighted term
> is copied in the Text Widget. I have already read the following node with
> what are - I guess - related problems:
> https://www.perlmonks.org/?node_id=1215349
> This problem prevents the use of any right-click features and should be
> addressed. Any workaround?
>
> Best,
> Welle

That does sound related to the general issue of middle-click and right-click (buttons 2 and 3) being swapped on macOS aqua (RT #125050, which I believe I had fixed in Tcl::pTk 0.93).

But what you're observing sounds more like both the intended right-click behavior (popup menu) as well the middle-click behavior (Unix-style shortcut to paste the selected text) happening at the same time. So far I cannot reproduce the issue in 0.94 with Tk 8.6.8, but I will look carefully again to see if there's something like extra `bind()` to the text or entry widget or one that I wrote backwards.

I doubt that it's your machine/trackpad that's sending a middle-click event, since there doesn't seem to be anything in System Preferences for doing that with a trackpad.

I'm curious what happens on your machine for an actual middle-click event (I would expect nothing to happen given your observation). If you don't happen to have a USB/bluetooth mouse with a middle button (clickable mouse wheel), would you be able to try using Karabiner-elements to emulate a button2 click from the keyboard?

On Sun Sep 16 08:01:52 2018, CAC wrote:
Show quoted text
> On Sun Sep 16 06:27:51 2018, welleozean@googlemail.com wrote:
> > Hello,
> >
> > Perl 5.28
> > macOS: HighSierra
> > Tcl: shipped with macOS
> > Tcl::pTk-0.94
> >
> > I found a strange behavior when right-clicking (I am using the
> > trackpad) on
> > any Widget that has a linked contextual menu (Text, Entry and so on):
> > the
> > menu is shown but at the same it seems to perform a copy and paste
> > operation. Simply try one of the demo widgets (widgetTclpTk->Basic
> > editable
> > text), highlight a word, and right-click on it. The popup is shown
> > and
> > after a while (the time windows seems to vary (?!?)) the highlighted
> > term
> > is copied in the Text Widget. I have already read the following node
> > with
> > what are - I guess - related problems:
> > https://www.perlmonks.org/?node_id=1215349
> > This problem prevents the use of any right-click features and should
> > be
> > addressed. Any workaround?
> >
> > Best,
> > Welle
>
> That does sound related to the general issue of middle-click and
> right-click
> (buttons 2 and 3) being swapped on macOS aqua (RT #125050, which I
> believe I
> had fixed in Tcl::pTk 0.93).
>
> But what you're observing sounds more like both the intended right-
> click
> behavior (popup menu) as well the middle-click behavior (Unix-style
> shortcut to
> paste the selected text) happening at the same time. So far I cannot
> reproduce
> the issue in 0.94 with Tk 8.6.8, but I will look carefully again to
> see if
> there's something like extra `bind()` to the text or entry widget or
> one that I
> wrote backwards.
>
> I doubt that it's your machine/trackpad that's sending a middle-click
> event,
> since there doesn't seem to be anything in System Preferences for
> doing that
> with a trackpad.
>
> I'm curious what happens on your machine for an actual middle-click
> event (I
> would expect nothing to happen given your observation). If you don't
> happen to
> have a USB/bluetooth mouse with a middle button (clickable mouse
> wheel), would
> you be able to try using Karabiner-elements to emulate a button2 click
> from the
> keyboard?

I suspect the old Tk version might be what's causing this. I didn't quickly find anything in Tcl::pTk's perl code responsible for the middle-click paste using a `bind()`, so I thought that it it might be handled by Tcl/Tk. I compared the Tcl/Tk widget demos for 8.5.9 and 8.6.8; and on 8.6.8, the paste happens for middle click, but for 8.5.9 it happens for right click. So the behavior for this seems to have changed between Tk 8.5.9 and 8.6.8. (I have not confirmed this from Tcl::pTk's widget demo with Tk 8.5.9, nor found a relevant commit/issue in Tk codebase.)

As for a workaround, I haven't yet found if I can override middle-click paste from Perl, i.e. for making sure it's using the right button even for older Tcl/Tk version.


On Sun Sep 16 08:30:35 2018, CAC wrote:
Show quoted text
> On Sun Sep 16 08:01:52 2018, CAC wrote:
> > On Sun Sep 16 06:27:51 2018, welleozean@googlemail.com wrote:
> > > Hello,
> > >
> > > Perl 5.28
> > > macOS: HighSierra
> > > Tcl: shipped with macOS
> > > Tcl::pTk-0.94
> > >
> > > I found a strange behavior when right-clicking (I am using the
> > > trackpad) on
> > > any Widget that has a linked contextual menu (Text, Entry and so
> > > on):
> > > the
> > > menu is shown but at the same it seems to perform a copy and paste
> > > operation. Simply try one of the demo widgets (widgetTclpTk->Basic
> > > editable
> > > text), highlight a word, and right-click on it. The popup is shown
> > > and
> > > after a while (the time windows seems to vary (?!?)) the
> > > highlighted
> > > term
> > > is copied in the Text Widget. I have already read the following
> > > node
> > > with
> > > what are - I guess - related problems:
> > > https://www.perlmonks.org/?node_id=1215349
> > > This problem prevents the use of any right-click features and
> > > should
> > > be
> > > addressed. Any workaround?
> > >
> > > Best,
> > > Welle
> >
> > That does sound related to the general issue of middle-click and
> > right-click
> > (buttons 2 and 3) being swapped on macOS aqua (RT #125050, which I
> > believe I
> > had fixed in Tcl::pTk 0.93).
> >
> > But what you're observing sounds more like both the intended right-
> > click
> > behavior (popup menu) as well the middle-click behavior (Unix-style
> > shortcut to
> > paste the selected text) happening at the same time. So far I cannot
> > reproduce
> > the issue in 0.94 with Tk 8.6.8, but I will look carefully again to
> > see if
> > there's something like extra `bind()` to the text or entry widget or
> > one that I
> > wrote backwards.
> >
> > I doubt that it's your machine/trackpad that's sending a middle-click
> > event,
> > since there doesn't seem to be anything in System Preferences for
> > doing that
> > with a trackpad.
> >
> > I'm curious what happens on your machine for an actual middle-click
> > event (I
> > would expect nothing to happen given your observation). If you don't
> > happen to
> > have a USB/bluetooth mouse with a middle button (clickable mouse
> > wheel), would
> > you be able to try using Karabiner-elements to emulate a button2
> > click
> > from the
> > keyboard?
>
> I suspect the old Tk version might be what's causing this. I didn't
> quickly
> find anything in Tcl::pTk's perl code responsible for the middle-click
> paste
> using a `bind()`, so I thought that it it might be handled by Tcl/Tk.
> I
> compared the Tcl/Tk widget demos for 8.5.9 and 8.6.8; and on 8.6.8,
> the paste
> happens for middle click, but for 8.5.9 it happens for right click. So
> the
> behavior for this seems to have changed between Tk 8.5.9 and 8.6.8. (I
> have not
> confirmed this from Tcl::pTk's widget demo with Tk 8.5.9, nor found a
> relevant
> commit/issue in Tk codebase.)
>
> As for a workaround, I haven't yet found if I can override middle-
> click paste
> from Perl, i.e. for making sure it's using the right button even for
> older
> Tcl/Tk version.

I believe this is the relevant commit in Tk, where <<PasteSelection>> becomes mapped to by <ButtonRelease-3> instead of <ButtonRelease-2> for aqua. The issue for the commit did not specify anything about the middle-click paste event. This change was released as part of Tk 8.5.16 and 8.6.1.
Subject: Re: [rt.cpan.org #127120] [macOS] Right-clic contextual menu
Date: Sun, 16 Sep 2018 18:46:38 +0200
To: bug-Tcl-pTk [...] rt.cpan.org
From: welle Ozean <welleozean [...] googlemail.com>
I confirm that with a middle-click event nothing happens (USB-Mouse). I tried the demo widget with the latest ActiveTcl 8.6.7 and the problem does not show up. I will give it a try and see if I can map the keys to fit the older Tk, even if for the moment I haven't found any solution. Am So., 16. Sep. 2018 um 15:52 Uhr schrieb Christopher Alexander Chavez via RT <bug-Tcl-pTk@rt.cpan.org>: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=127120 > > > On Sun Sep 16 08:30:35 2018, CAC wrote:
> > On Sun Sep 16 08:01:52 2018, CAC wrote:
> > > On Sun Sep 16 06:27:51 2018, welleozean@googlemail.com wrote:
> > > > Hello, > > > > > > > > Perl 5.28 > > > > macOS: HighSierra > > > > Tcl: shipped with macOS > > > > Tcl::pTk-0.94 > > > > > > > > I found a strange behavior when right-clicking (I am using the > > > > trackpad) on > > > > any Widget that has a linked contextual menu (Text, Entry and so > > > > on): > > > > the > > > > menu is shown but at the same it seems to perform a copy and paste > > > > operation. Simply try one of the demo widgets (widgetTclpTk->Basic > > > > editable > > > > text), highlight a word, and right-click on it. The popup is shown > > > > and > > > > after a while (the time windows seems to vary (?!?)) the > > > > highlighted > > > > term > > > > is copied in the Text Widget. I have already read the following > > > > node > > > > with > > > > what are - I guess - related problems: > > > > https://www.perlmonks.org/?node_id=1215349 > > > > This problem prevents the use of any right-click features and > > > > should > > > > be > > > > addressed. Any workaround? > > > > > > > > Best, > > > > Welle
> > > > > > That does sound related to the general issue of middle-click and > > > right-click > > > (buttons 2 and 3) being swapped on macOS aqua (RT #125050, which I > > > believe I > > > had fixed in Tcl::pTk 0.93). > > > > > > But what you're observing sounds more like both the intended right- > > > click > > > behavior (popup menu) as well the middle-click behavior (Unix-style > > > shortcut to > > > paste the selected text) happening at the same time. So far I cannot > > > reproduce > > > the issue in 0.94 with Tk 8.6.8, but I will look carefully again to > > > see if > > > there's something like extra `bind()` to the text or entry widget or > > > one that I > > > wrote backwards. > > > > > > I doubt that it's your machine/trackpad that's sending a middle-click > > > event, > > > since there doesn't seem to be anything in System Preferences for > > > doing that > > > with a trackpad. > > > > > > I'm curious what happens on your machine for an actual middle-click > > > event (I > > > would expect nothing to happen given your observation). If you don't > > > happen to > > > have a USB/bluetooth mouse with a middle button (clickable mouse > > > wheel), would > > > you be able to try using Karabiner-elements to emulate a button2 > > > click > > > from the > > > keyboard?
> > > > I suspect the old Tk version might be what's causing this. I didn't > > quickly > > find anything in Tcl::pTk's perl code responsible for the middle-click > > paste > > using a `bind()`, so I thought that it it might be handled by Tcl/Tk. > > I > > compared the Tcl/Tk widget demos for 8.5.9 and 8.6.8; and on 8.6.8, > > the paste > > happens for middle click, but for 8.5.9 it happens for right click. So > > the > > behavior for this seems to have changed between Tk 8.5.9 and 8.6.8. (I > > have not > > confirmed this from Tcl::pTk's widget demo with Tk 8.5.9, nor found a > > relevant > > commit/issue in Tk codebase.) > > > > As for a workaround, I haven't yet found if I can override middle- > > click paste > > from Perl, i.e. for making sure it's using the right button even for > > older > > Tcl/Tk version.
> > I believe this is the relevant commit in Tk, where <<PasteSelection>> > becomes > mapped to by <ButtonRelease-3> instead of <ButtonRelease-2> for aqua. The > issue > for the commit did not specify anything about the middle-click paste event. > This change was released as part of Tk 8.5.16 and 8.6.1. > >
On Sun Sep 16 11:47:03 2018, welleozean@googlemail.com wrote:
Show quoted text
> I confirm that with a middle-click event nothing happens (USB-Mouse).
> I
> tried the demo widget with the latest ActiveTcl 8.6.7 and the problem
> does
> not show up. I will give it a try and see if I can map the keys to fit
> the
> older Tk, even if for the moment I haven't found any solution.
>
> Am So., 16. Sep. 2018 um 15:52 Uhr schrieb Christopher Alexander
> Chavez via
> RT <bug-Tcl-pTk@rt.cpan.org>:
>
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=127120 >
> >
> > On Sun Sep 16 08:30:35 2018, CAC wrote:
> > > On Sun Sep 16 08:01:52 2018, CAC wrote:
> > > > On Sun Sep 16 06:27:51 2018, welleozean@googlemail.com wrote:
> > > > > Hello,
> > > > >
> > > > > Perl 5.28
> > > > > macOS: HighSierra
> > > > > Tcl: shipped with macOS
> > > > > Tcl::pTk-0.94
> > > > >
> > > > > I found a strange behavior when right-clicking (I am using the
> > > > > trackpad) on
> > > > > any Widget that has a linked contextual menu (Text, Entry and
> > > > > so
> > > > > on):
> > > > > the
> > > > > menu is shown but at the same it seems to perform a copy and
> > > > > paste
> > > > > operation. Simply try one of the demo widgets (widgetTclpTk-
> > > > > >Basic
> > > > > editable
> > > > > text), highlight a word, and right-click on it. The popup is
> > > > > shown
> > > > > and
> > > > > after a while (the time windows seems to vary (?!?)) the
> > > > > highlighted
> > > > > term
> > > > > is copied in the Text Widget. I have already read the following
> > > > > node
> > > > > with
> > > > > what are - I guess - related problems:
> > > > > https://www.perlmonks.org/?node_id=1215349
> > > > > This problem prevents the use of any right-click features and
> > > > > should
> > > > > be
> > > > > addressed. Any workaround?
> > > > >
> > > > > Best,
> > > > > Welle
> > > >
> > > > That does sound related to the general issue of middle-click and
> > > > right-click
> > > > (buttons 2 and 3) being swapped on macOS aqua (RT #125050, which
> > > > I
> > > > believe I
> > > > had fixed in Tcl::pTk 0.93).
> > > >
> > > > But what you're observing sounds more like both the intended
> > > > right-
> > > > click
> > > > behavior (popup menu) as well the middle-click behavior (Unix-
> > > > style
> > > > shortcut to
> > > > paste the selected text) happening at the same time. So far I
> > > > cannot
> > > > reproduce
> > > > the issue in 0.94 with Tk 8.6.8, but I will look carefully again
> > > > to
> > > > see if
> > > > there's something like extra `bind()` to the text or entry widget
> > > > or
> > > > one that I
> > > > wrote backwards.
> > > >
> > > > I doubt that it's your machine/trackpad that's sending a middle-
> > > > click
> > > > event,
> > > > since there doesn't seem to be anything in System Preferences for
> > > > doing that
> > > > with a trackpad.
> > > >
> > > > I'm curious what happens on your machine for an actual middle-
> > > > click
> > > > event (I
> > > > would expect nothing to happen given your observation). If you
> > > > don't
> > > > happen to
> > > > have a USB/bluetooth mouse with a middle button (clickable mouse
> > > > wheel), would
> > > > you be able to try using Karabiner-elements to emulate a button2
> > > > click
> > > > from the
> > > > keyboard?
> > >
> > > I suspect the old Tk version might be what's causing this. I didn't
> > > quickly
> > > find anything in Tcl::pTk's perl code responsible for the middle-
> > > click
> > > paste
> > > using a `bind()`, so I thought that it it might be handled by
> > > Tcl/Tk.
> > > I
> > > compared the Tcl/Tk widget demos for 8.5.9 and 8.6.8; and on 8.6.8,
> > > the paste
> > > happens for middle click, but for 8.5.9 it happens for right click.
> > > So
> > > the
> > > behavior for this seems to have changed between Tk 8.5.9 and 8.6.8.
> > > (I
> > > have not
> > > confirmed this from Tcl::pTk's widget demo with Tk 8.5.9, nor found
> > > a
> > > relevant
> > > commit/issue in Tk codebase.)
> > >
> > > As for a workaround, I haven't yet found if I can override middle-
> > > click paste
> > > from Perl, i.e. for making sure it's using the right button even
> > > for
> > > older
> > > Tcl/Tk version.
> >
> > I believe this is the relevant commit in Tk, where <<PasteSelection>>
> > becomes
> > mapped to by <ButtonRelease-3> instead of <ButtonRelease-2> for aqua.
> > The
> > issue
> > for the commit did not specify anything about the middle-click paste
> > event.
> > This change was released as part of Tk 8.5.16 and 8.6.1.
> >
> >

Looking at the Tk source code (tk.tcl), it turns out that the relevant statement `event add <<PasteSelection>> <ButtonRelease-2>` is easily undone by `event delete <<PasteSelection>> <ButtonRelease-2>`. Then using `event add <<PasteSelection>> <ButtonRelease-3>` effectively fixes the behavior in Tk at runtime. Here's the workaround I'm thinking of putting in Tcl::pTk (I'm not yet sure exactly where it would belong):

# RT #127120: Middle-click paste workaround
Show quoted text
# for older Tcl/Tk versions on macOS aqua
if ($MW->windowingsystem eq 'aqua'){
    # Check for affected versions of Tk
    if (
        ($MW->tclVersion eq '8.4')
        or (($MW->tclVersion eq '8.5') and ($MW->tclPatchlevel lt '8.5.16'))
        or (($MW->tclVersion eq '8.6') and ($MW->tclPatchlevel lt '8.6.1'))
    ) {
        # Remove the wrong binding (right button)
        $MW->interp->Eval('event delete <<PasteSelection>> <ButtonRelease-2>');
        # Replace it with the correct binding (middle button)
        $MW->interp->Eval('event delete <<PasteSelection>> <ButtonRelease-3>');
    }
}
Subject: Re: [rt.cpan.org #127120] [macOS] Right-clic contextual menu
Date: Mon, 17 Sep 2018 14:27:36 +0200
To: bug-Tcl-pTk [...] rt.cpan.org
From: welle Ozean <welleozean [...] googlemail.com>
Brilliant. The patch seems to work. I slightly adapted it and inserted it directly in my application. Of course it would be great for other users to have it directly in Tcl::pTk I have only one observation $MW->tclPatchlevel lt '8.5.16' doesn't seem to work. If the value on the left is 8.5.9 the comparison's result is FALSE, as I guess 9 is considered like 90 and therefore bigger than 16. Am Mo., 17. Sep. 2018 um 07:17 Uhr schrieb Christopher Alexander Chavez via RT <bug-Tcl-pTk@rt.cpan.org>: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=127120 > > > On Sun Sep 16 11:47:03 2018, welleozean@googlemail.com wrote:
> > I confirm that with a middle-click event nothing happens (USB-Mouse). > > I > > tried the demo widget with the latest ActiveTcl 8.6.7 and the problem > > does > > not show up. I will give it a try and see if I can map the keys to fit > > the > > older Tk, even if for the moment I haven't found any solution. > > > > Am So., 16. Sep. 2018 um 15:52 Uhr schrieb Christopher Alexander > > Chavez via > > RT <bug-Tcl-pTk@rt.cpan.org>: > >
> > > <URL: https://rt.cpan.org/Ticket/Display.html?id=127120 > > > > > > > On Sun Sep 16 08:30:35 2018, CAC wrote:
> > > > On Sun Sep 16 08:01:52 2018, CAC wrote:
> > > > > On Sun Sep 16 06:27:51 2018, welleozean@googlemail.com wrote:
> > > > > > Hello, > > > > > > > > > > > > Perl 5.28 > > > > > > macOS: HighSierra > > > > > > Tcl: shipped with macOS > > > > > > Tcl::pTk-0.94 > > > > > > > > > > > > I found a strange behavior when right-clicking (I am using the > > > > > > trackpad) on > > > > > > any Widget that has a linked contextual menu (Text, Entry and > > > > > > so > > > > > > on): > > > > > > the > > > > > > menu is shown but at the same it seems to perform a copy and > > > > > > paste > > > > > > operation. Simply try one of the demo widgets (widgetTclpTk-
> > > > > > >Basic
> > > > > > editable > > > > > > text), highlight a word, and right-click on it. The popup is > > > > > > shown > > > > > > and > > > > > > after a while (the time windows seems to vary (?!?)) the > > > > > > highlighted > > > > > > term > > > > > > is copied in the Text Widget. I have already read the following > > > > > > node > > > > > > with > > > > > > what are - I guess - related problems: > > > > > > https://www.perlmonks.org/?node_id=1215349 > > > > > > This problem prevents the use of any right-click features and > > > > > > should > > > > > > be > > > > > > addressed. Any workaround? > > > > > > > > > > > > Best, > > > > > > Welle
> > > > > > > > > > That does sound related to the general issue of middle-click and > > > > > right-click > > > > > (buttons 2 and 3) being swapped on macOS aqua (RT #125050, which > > > > > I > > > > > believe I > > > > > had fixed in Tcl::pTk 0.93). > > > > > > > > > > But what you're observing sounds more like both the intended > > > > > right- > > > > > click > > > > > behavior (popup menu) as well the middle-click behavior (Unix- > > > > > style > > > > > shortcut to > > > > > paste the selected text) happening at the same time. So far I > > > > > cannot > > > > > reproduce > > > > > the issue in 0.94 with Tk 8.6.8, but I will look carefully again > > > > > to > > > > > see if > > > > > there's something like extra `bind()` to the text or entry widget > > > > > or > > > > > one that I > > > > > wrote backwards. > > > > > > > > > > I doubt that it's your machine/trackpad that's sending a middle- > > > > > click > > > > > event, > > > > > since there doesn't seem to be anything in System Preferences for > > > > > doing that > > > > > with a trackpad. > > > > > > > > > > I'm curious what happens on your machine for an actual middle- > > > > > click > > > > > event (I > > > > > would expect nothing to happen given your observation). If you > > > > > don't > > > > > happen to > > > > > have a USB/bluetooth mouse with a middle button (clickable mouse > > > > > wheel), would > > > > > you be able to try using Karabiner-elements to emulate a button2 > > > > > click > > > > > from the > > > > > keyboard?
> > > > > > > > I suspect the old Tk version might be what's causing this. I didn't > > > > quickly > > > > find anything in Tcl::pTk's perl code responsible for the middle- > > > > click > > > > paste > > > > using a `bind()`, so I thought that it it might be handled by > > > > Tcl/Tk. > > > > I > > > > compared the Tcl/Tk widget demos for 8.5.9 and 8.6.8; and on 8.6.8, > > > > the paste > > > > happens for middle click, but for 8.5.9 it happens for right click. > > > > So > > > > the > > > > behavior for this seems to have changed between Tk 8.5.9 and 8.6.8. > > > > (I > > > > have not > > > > confirmed this from Tcl::pTk's widget demo with Tk 8.5.9, nor found > > > > a > > > > relevant > > > > commit/issue in Tk codebase.) > > > > > > > > As for a workaround, I haven't yet found if I can override middle- > > > > click paste > > > > from Perl, i.e. for making sure it's using the right button even > > > > for > > > > older > > > > Tcl/Tk version.
> > > > > > I believe this is the relevant commit in Tk, where <<PasteSelection>> > > > becomes > > > mapped to by <ButtonRelease-3> instead of <ButtonRelease-2> for aqua. > > > The > > > issue > > > for the commit did not specify anything about the middle-click paste > > > event. > > > This change was released as part of Tk 8.5.16 and 8.6.1. > > > > > >
> > Looking at the Tk source code (tk.tcl), it turns out that the relevant > statement `event add <<PasteSelection>> <ButtonRelease-2>` is easily > undone by > `event delete <<PasteSelection>> <ButtonRelease-2>`. Then using `event add > <<PasteSelection>> <ButtonRelease-3>` effectively fixes the behavior in Tk > at > runtime. Here's the workaround I'm thinking of putting in Tcl::pTk (I'm > not yet > sure exactly where it would belong): > > # RT #127120: Middle-click paste workaround > # for older Tcl/Tk versions on macOS aqua > if ($MW->windowingsystem eq 'aqua'){ > # Check for affected versions of Tk > if ( > ($MW->tclVersion eq '8.4') > or (($MW->tclVersion eq '8.5') and ($MW->tclPatchlevel lt '8.5.16')) > or (($MW->tclVersion eq '8.6') and ($MW->tclPatchlevel lt '8.6.1')) > ) { > # Remove the wrong binding (right button) > $MW->interp->Eval('event delete <<PasteSelection>> <ButtonRelease-2>'); > # Replace it with the correct binding (middle button) > $MW->interp->Eval('event delete <<PasteSelection>> <ButtonRelease-3>'); > } > } > >
On Mon Sep 17 07:28:00 2018, welleozean@googlemail.com wrote:
Show quoted text
> Brilliant. The patch seems to work. I slightly adapted it and inserted it
> directly in my application. Of course it would be great for other users to
> have it directly in Tcl::pTk
>
> I have only one observation
> $MW->tclPatchlevel lt '8.5.16'
> doesn't seem to work. If the value on the left is 8.5.9 the comparison's
> result is FALSE, as I guess 9 is considered like 90 and therefore bigger
> than 16.

Thank you for trying this out, and for catching the naïve comparison I wrote. You're right, it won't work for comparing versions with different numbers of digits. Nor will it handle alpha/beta releases e.g. '8.7a2'…

Also, at the moment I think it's likely that once the workaround is in Tcl::pTk, you might want to remove it from your program to prevent any errors from it doing the same thing twice.

On Mon Sep 17 09:01:06 2018, CAC wrote:
Show quoted text
> On Mon Sep 17 07:28:00 2018, welleozean@googlemail.com wrote:
> > Brilliant. The patch seems to work. I slightly adapted it and
> > inserted it
> > directly in my application. Of course it would be great for other
> > users to
> > have it directly in Tcl::pTk
> >
> > I have only one observation
> > $MW->tclPatchlevel lt '8.5.16'
> > doesn't seem to work. If the value on the left is 8.5.9 the
> > comparison's
> > result is FALSE, as I guess 9 is considered like 90 and therefore
> > bigger
> > than 16.
>
> Thank you for trying this out, and for catching the naïve comparison I
> wrote.
> You're right, it won't work for comparing versions with different
> numbers of
> digits. Nor will it handle alpha/beta releases e.g. '8.7a2'…
>
> Also, at the moment I think it's likely that once the workaround is in
> Tcl::pTk, you might want to remove it from your program to prevent any
> errors
> from it doing the same thing twice.

I found that a more robust way to check the Tcl/Tk version (or patchlevel) is to just use Tcl's package vcompare command, rather than to try inventing my own. Using that, I have incorporated a revised way of patching old Tk Aqua at runtime, as well as added a test to check that the middle-click paste behavior is correct regardless of the version of Tk Aqua present: https://github.com/chrstphrchvz/perl-tcl-ptk/commit/068b11022878322daa962520b9d48768bbf3e1d8