ozboomer has asked for the wisdom of the Perl Monks concerning the following question:
However I'm having troubles with callbacks now. I've not used them in my perl very much and the following code shows an example of what I'm trying to do:
I'm expecting to get the integer that JComboBox->getSelectedIndex() returns passed into the sub and that is, indeed what happens when I use a number but the result of the method call isn't being passed.use Tk; use Tk::JComboBox; my $mw = MainWindow->new(); my $jcb = $mw->JComboBox( -relief => 'sunken', -mode => 'editable', -listbackground => 'white', -popuprelief => 'groove', -highlightthickness => 0, -choices => [qw/Black Blue Green Purple Red Yellow/] )->pack; $mw->Button( -text => 'func', -command => [ \&test, $jcb->getSelectedValue($jcb->getSelectedIndex()) ], # -command => [ \&test, 2 ], )->pack; $mw->Button( -text => 'embed', -command => [ sub { my ($p1); printf("e: \$p1 = >>$p1<<\n"); }, $jcb->getSelectedIndex() ] )->pack; MainLoop; sub test { my ($p1) = @_; printf("f: \$p1 = >$p1<\n"); }
I've looked through this site but haven't been able to find anything that talks about the getSelectedIndex() method and what it returns. The docs. for JComboBox just talk about returning an index and not how to pass that value elsewhere.
Apologies for the basic question... but my experiments and research have hit a brick wall!
Many thanks for any forthcoming suggestions.
John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is the problem JComboBox, Perl/Tk or (probably) me!?
by eserte (Deacon) on May 14, 2004 at 13:03 UTC | |
|
Re: Is the problem JComboBox, Perl/Tk or (probably) me!?
by Joost (Canon) on May 14, 2004 at 13:14 UTC | |
|
Re: Is the problem JComboBox, Perl/Tk or (probably) me!?
by ozboomer (Friar) on May 14, 2004 at 13:29 UTC | |
by zentara (Cardinal) on May 14, 2004 at 15:59 UTC |