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

Dear Monks

I am trying to set up an action using radio buttons that when it is selected it changes the readonly state of the text field (see below code). This code runs but the subroutine does not work when the radio button is selected. I expect that the –click option is not doing what I want it to do, and my googling for solutions technique is not yielding any suggestions. Does anyone have any suggestions on how to get the functionality that I am looking for?

#!perl -w use strict; #use warnings; use Win32::GUI(); my $w = 250; my $h = 100; my $main = Win32::GUI::Window->new( -name => 'Main', -text => 'Example Window', -width => $w, -height => $h, -resizable => 0 ); $main->AddRadioButton ( -name => 'radio_1', -pos => [10, 10], -size => [12,12], -checked => '1', -click => sub{$main->user_text->Change(-readonly => 1);}, ); $main->AddLabel( -text => "Disable Textfield", -pos => [25,10], ); $main->AddRadioButton ( -name => 'radio_2', -pos => [10, 30], -size => [12,12], -click => sub{$main->user_text->Change(-readonly => 0);}, ); $main->AddLabel( -text => "Enable Textfield", -pos => [25,30], ); $main->AddTextfield( -name => 'user_text', -pos => [110,28], -size => [60,20], -align => 'left', -readonly => 1, ); $main->Show(); Win32::GUI::Dialog();

Replies are listed 'Best First'.
Re: Win32:GUI question
by ikegami (Patriarch) on Feb 24, 2010 at 20:20 UTC
      Godsend... Perfect. I got to caught up in trying to get Change to work I did not look for other solutions. Thank you very much for your help.
        From what I can tell, Change is a callback that gets called when the text of the control changes. It can't be used to change anything.
Re: Win32:GUI changing readonly question
by sierpinski (Chaplain) on Feb 24, 2010 at 19:45 UTC
    It's been a while since I did any Dynamic HTML, but if I recall correctly, to get a form object to change, you either need to use something like javascript, or reload the page. I didn't think Perl could do that, since it's executed on the server and not on the client, like javascript is.
    /\ Sierpinski
      Hi Sierpinski, this is actually all contained in a Windows program versus HTML... Thanks for trying to help.
Re: Win32:GUI question
by ikegami (Patriarch) on Feb 24, 2010 at 20:23 UTC
    [ Duplicate post. Please ignore ]