I have an app which has two radio buttons. One is a text field which controls a date range ((today -1) - text field value to create a date. The other is a set of two DateTime controls. The problem I am having is that when one changes, I want the other to change in response: Here are the DateTime change event handlers:
sub Start_Change { my $date1 = sprintf "%04d%02d%02d", ($win->End->GetDate())[2,1,0]; my $date2 = sprintf "%04d%02d%02d", ($win->Start->GetDate())[2,1,0]; $win->tfDays->Text( $date1 - $date2); } sub End_Change { my $date1 = sprintf "%04d%02d%02d", ($win->End->GetDate())[2,1,0]; my $date2 = sprintf "%04d%02d%02d", ($win->Start->GetDate())[2,1,0]; $win->tfDays->Text( $date1 - $date2); } and here is the Text field event handler: sub tfDays_Change { my $date = sprintf "%04d-%02d-%02d", ($win->End->GetDate())[2,1,0]; my $start = Date::Simple->new($date); my $end = $start - $win->tfDays->Text(); $win->Start->SetDate(reverse(split("-", $end))); } Now, here is my problem: When I change the days in the text box, I do not have a problem, but when I change the date using the DateTime (even just scrolling between months), the days in the text field change, which causes the datetime to change, which causes the text field to change.... I think everyone can understand the rest. What I am looking for is a way to have the $win->tfDays->Text( $date1 - $date2) to NOT call the tfDays_Change event. I assume there is a way to temporarily detach the event handler from the object and then reattach using Hook/Unhook, but I cannot find any examples. Can anyone help with an example in using the Hook/Unhook methods? Thanks, Joe Frazier, Jr.