perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
I seem to be running into an "oddity".
There are "handler" functions, in Tk, that can be called when events happen like keyboard or timer input.
I'm running into a "unique" problem from the object oriented structure I'm converting to. When my classes are being called from a Tk event handler, calls are not finding "base" or ancestor "methods" in handler routines. Sample error messages:
Both "write_filedb" and "next_rand_or_recorded_file" are in Base classes of the handler routines.Tk::Error: Undefined subroutine &Entry_Display_In_Wins::next_rand_or_r +ecorded_file called at shown.pl line 1403. <Key> (command bound to event) at blib/lib/Tk.pm (autosplit into blib/lib/auto/Tk/Error.al) line 488 Tk::Error('MainWindow=HASH(0x667084)', 'Undefined subroutine &Entr +y_Display_In_Wins::next_rand_or_rec...', '<Key>', '(command bound to +event)') called at /usr/lib/perl5/vendor_perl/5.8/cygwin/Tk.pm line 4 +06 eval {...} called at /usr/lib/perl5/vendor_perl/5.8/cygwin/Tk.pm l +ine 406 Tk::MainLoop called at shown.pl line 1720 main::main() called at shown.pl line 1727 ---- and ---- Tk::Error: Undefined subroutine &Entry_Display_In_Wins::write_db calle +d at shown.pl line 1392. <Key> (command bound to event) at blib/lib/Tk.pm (autosplit into blib/lib/auto/Tk/Error.al) line 488 Tk::Error('MainWindow=HASH(0x667084)', 'Undefined subroutine &Entr +y_Display_In_Wins::write_db cal...', '<Key>', '(command bound to even +t)') called at /usr/lib/perl5/vendor_perl/5.8/cygwin/Tk.pm line 406 eval {...} called at /usr/lib/perl5/vendor_perl/5.8/cygwin/Tk.pm l +ine 406 Tk::MainLoop called at shown.pl line 1720 main::main() called at shown.pl line 1727
Relevant packages are like this
I've disabled timer ticks for now, so only events coming in are from keyboard, but got similar error:package File_Rating_DB; #pckg ONE sub write_db(){}... package Entry_Ordering; #pckg TWO our @ISA = qw(File_Rating_DB); sub next_rand_or_recorded_file() {}... package Entry_Display_In_Wins; #pckg THREE our @ISA = qw(Entry_Ordering); sub __hk_space(){ call next_rand_or_recorded_file}... sub __hk_quit(){ ...calls write_db on exit } sub handle_key($tkcontext,$dbhandle,$key_event, $key_code) {} package Timed_Display_In_Wins; #pckg FOUR our @ISA = qw(Entry_Display_In_Wins); sub _handle_timer(){}
As may or may not be evident, the handler routines are located in pckg's THREE and FOUR, and try to call routines in pckg's TWO and ONE.
Any special "magic" I was supposed to use to get my handling routine's "base" classes to be searched?
It is, as if is "losing" my "Base" classes as it enters into my "handler(s)" from Tk.
Focusing on the keyboard, I bind it with:
so the routines are called like "$main_win->handle_key($s, Ev('A'), Ev('K'))", where "$s" is the main "self" data structure/pointer.$main_win->bind('<Any-KeyPress>'=>[\&handle_key, $s,Ev('A'), Ev('K')]) +;
Subroutines in the same "package" seem to be called correctly, like "handle_key->calls->hk_space, but hk_space can't find "next_rand_or_recorded" from its parent.
What am I missing? :-?
Thanks!
Linda
|
|---|