Oh, and I should mention that I tried it using the $widget->SelectionOption() methods as well:

#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new(); $mw->SelectionHandle( -selection => 'CLIPBOARD', sub { return 'clip' } + ); $mw->SelectionOwn( -selection => 'CLIPBOARD' );

It gives the same error (in xclipboard). :-( Whereas the following works just fine:

#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new(); $mw->SelectionHandle( -selection => 'PRIMARY', sub { return 'clip' } ) +; $mw->SelectionOwn( -selection => 'PRIMARY' );

Update: Hrm. Upon further testing, I find that the 'PRIMARY' selection was not actually working between applications. It owns the selection ok (ie, whatever was selected before, is no longer), and I can insert the selection properly within my own application but it does not show up in other applications.

Upon further further testing, I find that it all works just fine if I have a MainLoop in my program. Now all I have to do is find a way to get it to execute a single loop and then exit. I thought there was an easy way to do that but I cannot seem to find it. I can always resort to some chicanery involving $mw->after() ...

Does anyone know a function that will execute a single Perl/Tk event loop, and then return?

bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.


In reply to (bbfu) (neither $widget-SelectionHandle()) Re: Tk::Clipboard and the X Windows Clipboard by bbfu
in thread Tk::Clipboard and the X Windows Clipboard by bbfu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.