Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

GUI question: Prima: password input fields

by docsnyder (Novice)
on Dec 21, 2019 at 10:32 UTC ( #11110465=perlquestion: print w/replies, xml ) Need Help??

docsnyder has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks!

I am using Prima for creating GUI's and I am trying to handle a password input field with characters entered shown as '*'.

I have figured out, that this is achieved by setting the attribute 'writeOnly' of the InputLine to 'true'. But, how can I access the entered password in clear text in order to process it? Accessing it via the 'text()' method just return the hidden password (e.g. '*******'). Even setting 'writeOnly' to 'false' does not show the characters entered before in 'asterisk mode' in clear text.

I have stufied the Prima example, but even with this example I am not able to retrieve clear text from the input field, once the characters have been asterisked.

Any experience/idea?. Any hint would be appreciated!


  • Comment on GUI question: Prima: password input fields

Replies are listed 'Best First'.
Re: GUI question: Prima: password input fields
by roboticus (Chancellor) on Dec 21, 2019 at 13:56 UTC


    I've installed Prima years ago, but never got around to trying it out. (It's still on my To-Do list.)

    But in the installation is an examples directory, so I looked around in there. If you take a look at the examples/ script, it shows how you can use the password mode on an input control. I just ran it, and it worked just fine, so give it a look.

    You'll also want to look over the other examples when you're trying to figure out a feature. You might also look over the tests as well--I do that in any case for modules when I'm trying to figure out how to make something work.


    When your only tool is a hammer, all problems look like your thumb.

Re: GUI question: Prima: password input fields
by Anonymous Monk on Dec 21, 2019 at 12:57 UTC

    subclass and override sub edit_text

    sub edit_text { my ($self, $text) = @_; $self->{password} = $text; $self-> begin_undo_group; $self-> push_undo_action( 'edit_text', $self->text); $self-> text($text); $self-> end_undo_group; }

    or patch

    $self->{password} = $cap; $cap = $self-> {passwordChar} x length $cap if $self-> {writeO +nly}; $self-> {wholeLine} = $cap;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11110465]
Front-paged by haukex
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2021-04-22 17:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found