Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

How can I get Prima to display things from top to bottom?

by ZJ.Mike.2009 (Scribe)
on Jun 03, 2011 at 07:03 UTC ( #907913=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://907913]
Approved by shmem
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2023-02-01 15:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (10 votes). Check out past polls.

    Notices?