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();

In reply to Win32:GUI question by drblove27

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.