I did some testing,
\n not found.
use Tk;
use Tk::Dialog;
use Tk::TableMatrix;
my $mw = MainWindow->new;
$mw->minsize(600, 300); # minimum size of main window in pixels
+
my $textfont = '-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*';
my $arrayVar = {};
while (<DATA>) {
my $i = $. - 1;
/^([^\t]*)\t([^\t]*)/;
$arrayVar->{"$i,0"} = "$1";
$arrayVar->{"$i,1"} = "$2";
}
my $t = $mw->Scrolled('TableMatrix',
-scrollbars => "osoe",
-font => $textfont,
-resizeborders => 'none',
-rows => 3,
-cols => 2,
-wrap => 1,
-rowheight => 4,
-variable => $arrayVar,
-colstretchmode => 'all',
);
my $buttexit = $mw->Button( -text => "Exit", -command => sub{ $mw->des
+troy});
my $buttinfo = $mw->Button( -text => "View cellinfo", -command => sub{
my $cursorpos = $t->icursor();
my $activecont = $t->get(active);
my $activeindex = $t->index('active');
my $linebreak;
if ($activecont =~ /\n/) {$linebreak = "found"} else {$linebreak =
+ "not found"};
$mw->Dialog( -title => 'Info',
-text => "current cell contains:\n\n$a
+ctivecont\n\nindex of active cell: $activeindex\nCursor position with
+in cell: $cursorpos\n\nLine break $linebreak",
-default_button => 'OK',
-buttons => ['OK']
)->Show( );
});
$t->pack(-expand => 1, -fill => 'both');
$buttexit->pack(-expand => 1, -fill => 'both');
$buttinfo->pack(-expand => 1, -fill => 'both');
Tk::MainLoop;
__DATA__
this is a relatively long string that will probably end up displayed o
+n two lines if the window isn't wide enough blabla
foo bar
tralla lalala
When I click into the cell with the long text and click the View cell info button, the dialog shows the text without line breaks and reports that \n is "not found".
Am I doing something wrong or is this approach a dead end?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.