in reply to Re: Win32::GUI Issues
in thread Win32::GUI Issues

This is the AddTextfield code i have that you were asking for there is no way that i have found (looked all over the net and my books) to do an enter event for this Widget. I.E. i want to have an event handler for when the user hits the ENTER key inside this Widget, so that i can invoke the same code that happens if they use the mouse to click the "Update Wafers" button.
my $lotid = $main->AddTextfield( -name => "lotid", -keepselection => 1, -top => $row0, -left => $col1, -width => 125, -height => 20, -font => $t_font, -readonly => 0, );

The other question about changing the size of the ComboBox Widget independantly of the Dropdown size or FONT was my intention. As memtioned before i can make the font smaller and its size will decrease, i just thought maybe i could get rid of some of the whitespace that resided on top and bottom of the FONT that im using. I ended up just decreasing the size by 2 pts and it fits fine now.

Replies are listed 'Best First'.
Re^3: Win32::GUI Issues
by ChrisR (Hermit) on Apr 21, 2005 at 18:49 UTC
    I don't think you can use the Win32::GUI::AcceleratorTable for a widget ( I couldn't get tit to work for the Textfield anyway ). But here is some code that does what you are looking for. At least I think it does. You should really post more code to show the situation you are dealing as well as tell us what you have tried so far. Anyway, here's some code that gives an example of at least one way to do it:
    #!c:\perl\wperl.exe -w use strict; use warnings; use Win32::GUI; my $t_font = Win32::GUI::Font->new( -name => "Arial", -size => 7 ); my $accelerators = new Win32::GUI::AcceleratorTable("Return" => "Enter +"); my $main = Win32::GUI::Window->new(-name=>'main',-text=>'test',-width= +>200,-height=>200,-dialogui=>1,-accel=>$accelerators); my $button1 = $main->AddButton(-name=>'button1',-top=>10,-left=>10,-te +xt=>"button1",-ok=>0); my $lotid = $main->AddTextfield( -name => "lotid", -keepselection => 1, -top => 30, -left => 10, -width => 125, -height => 20, -font => $t_font, -readonly => 0, ); my $lotid_hwnd = $main->lotid->{-handle}; #print "Handle of the lotid textfield: $lotid_hwnd\n"; $main->Show(); Win32::GUI::Dialog(); exit; sub Enter_Click { my $control_hwnd = $main->GetFocus(); #print "handle of the control with the focus: $control_hwnd\n"; if($control_hwnd == $lotid_hwnd) { $main->MessageBox("You pressed Return in while in the textfiel +d. This is what was int he textfield: \"" . $lotid->Text() . "\"","En +ter_Click"); button1_Click(); } else { $main->MessageBox("You pressed Return in while NOT in the text +field.","Enter_Click"); } return 1; } sub button1_Click { $main->MessageBox("You clicked button1.","button1"); } sub main_Termintate { $main->Hide(); return -1; }