I have been trying to change the default button in a Win32::GUI script and have not had any luck. By default, I mean the button that gets its Click event called when I hit the enter key. As I understand it, the
-default option sets the dark border around the button and the
-ok option sets the
action default. While getting the dark border around the button is nice, it is not necessarry in my application. I have tried quite a few different things and, of course, none of them worked. Here is an example of my last feable attmept:
use strict;
use Win32::GUI;
my $mainform = Win32::GUI::Window->new(-name=>'main',-text=>'test',-wi
+dth=>200,-height=>200,-dialogui=>1);
my $button1 = $mainform->AddButton(-name=>'button1',-top=>10,-left=>10
+,-text=>"button1",-ok=>1);
my $button2 = $mainform->AddButton(-name=>'button2',-top=>40,-left=>10
+,-text=>"button2",-ok=>0);
$mainform->Show();
Win32::GUI::Dialog();
exit;
sub button1_Click
{
$mainform->MessageBox("You clicked button1. Changing the default
+to button2.","button1");
$button1->Change(-ok=>0);
$button2->Change(-ok=>1);
}
sub button2_Click
{
Win32::GUI->MessageBox("You clicked button2. Changing the default
+ to button1.","button2");
$button2->Change(-ok=>0);
$button1->Change(-ok=>1);
}
sub main_Termintate
{
$mainform->Hide();
return -1;
}
I have tried all sorts of combinations using the
-default and
-ok options like only setting one or the other or setting them to different values and have gotten nowhere. Is this even possible? I thought perhaps I needed to refresh the window, but I can't seem to find a function to do that other than those dealing with redraws. I tried to
Hide() the window before making the change and then
Show() the window after the change which makes the change of
-default show up but nothing more. Any help would be greatly appreciated.
Thanks,
Chris
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.