http://qs1969.pair.com?node_id=907913

ZJ.Mike.2009 has asked for the wisdom of the Perl Monks concerning the following question:

Just starting to play with Prima. Wrote the following code:
use strict; use warnings; use Prima qw(Application Edit Buttons); my $window = new Prima::MainWindow( size => [ 250, 350] ); my $display_field = $window->insert( Edit => size => [ 200, 300], text => '', centered => 1, ); my $butoon = $window->insert( Button => size => [ 50, 20], text => 'Click', place => { x => 120, y => 340 }, onClick => \&button_Click, ); sub button_Click { for (1..5) { $display_field->insert_text("$_\n\n"); } } run Prima;
I expected the display field shows 1 2 3 4 and 5 separately in each line from top to bottom but Prima gives me 5 4 3 2 1. Things get displayed upside down.

I've noticed the x and y coordinates in Prima are different. For example, the x coordinate in Prima starts from left bottom corner of the widget, rather than the usual left top corner. I've found some seemingly relevant methods like translate, but I cant't seem to figure out how to get things displayed the expected way? Does someone have some ideas?

Thanks in advance.

Replies are listed 'Best First'.
Re: How can I get Prima to display things from top to bottom?
by Anonymous Monk on Jun 03, 2011 at 07:23 UTC
    Prima::Edit
    insert_text TEXT, [ HIGHLIGHT = 0 ] Inserts TEXT at the cursor position. If HIGHLIGHT is set to 1, the selection block is cancelled and the newly inserted text is selected.
    So the solution is to move the cursor
    $display_field->cursor_cend; $display_field->insert_text("$_\n\n");
    Honestly, there are no things
      Great! Things work now. Thanks Anonymous Monk!
Re: How can I get Prima to display things from top to bottom?
by Anonymous Monk on Jun 03, 2011 at 07:13 UTC