CALLBACKS in ConfigSpecs 
Author Message
 CALLBACKS in ConfigSpecs

  Hi Tkers,

  I'm trying to derive a widget with a default callback. The actual
  case involves a TableMatrix (and is described below), but I've
  included a little
  example involving a DemoButton derived from a Button. For the
  purposes of the example I want DemoButton to have a default
  command callback, so I include a ConfigSpec line.

         $self->ConfigSpecs(
              -command=>['CALLBACK','command','Command',sub {
                   print "Default command\n";
                   }],
         );

  If the user includes their own -command option, I want to
  save it and chain it onto the end of the default command. However
  I can't get the basic default command callback to work yet.

  Any help would be greatly appreciated.

  I'm using Tk800.024 on Linux.

  Cheers,

  Geoff Russell

My little examples are in 2 attachments. The completed EntryTableMatrix
widget will be posted when complete.

P.S. The actual situation involves using a TableMatrix with a default
browsecommand which moves an Entry widget into the current cell
so that users can operate in cells of a table matrix in
exactly the same way as any Entry. If I provide the browsecommand
explicitly it all works fine, but I can't seem to package it
into the mega widget.

    Geoff Russell

[ DemoButton.pm < 1K ]
#
## vim: foldmethod=manual
#
package Tk::DemoButton;

$Tk::DemoButton::VERSION='1.0';

use Tk::widgets qw/Button/;

use base qw(Tk::Derived Tk::Button);

use strict;

Construct Tk::Widget 'DemoButton';

sub ClassInit {

        print "CLASSINIT\n";
        $class->SUPER::ClassInit($mw);

Quote:
}

sub Populate {

        print "POPULATE\n";
        $self->SUPER::Populate($args);

        $self->ConfigSpecs(
                -bg=>'-background',
                -fg=>'-foreground',
                -command=>['CALLBACK','command','Command',sub {
                        print "Default command\n";
                        }],
        );
# This doesn't do anything either
        $self->configure(-command=>sub { print "DemoButton\n"; });

Quote:
}

1;

  tDemoButton
< 1K Download


Thu, 24 Mar 2005 13:00:22 GMT  
 CALLBACKS in ConfigSpecs

Quote:

>   Hi Tkers,

>   I'm trying to derive a widget with a default callback. The actual
>   case involves a TableMatrix (and is described below), but I've
>   included a little
>   example involving a DemoButton derived from a Button. For the
>   purposes of the example I want DemoButton to have a default
>   command callback, so I include a ConfigSpec line.

>          $self->ConfigSpecs(
>               -command=>['CALLBACK','command','Command',sub {
>                    print "Default command\n";
>                    }],
>          );

This will work if you use 'SELF' instead of 'CALLBACK'.

- Show quoted text -

Quote:

>   If the user includes their own -command option, I want to
>   save it and chain it onto the end of the default command. However
>   I can't get the basic default command callback to work yet.

>   Any help would be greatly appreciated.

>   I'm using Tk800.024 on Linux.

>   Cheers,

>   Geoff Russell

> My little examples are in 2 attachments. The completed EntryTableMatrix
> widget will be posted when complete.

> P.S. The actual situation involves using a TableMatrix with a default
> browsecommand which moves an Entry widget into the current cell
> so that users can operate in cells of a table matrix in
> exactly the same way as any Entry. If I provide the browsecommand
> explicitly it all works fine, but I can't seem to package it
> into the mega widget.

[...]

> --------------050002060606050806030103
> Content-Type: application/x-java-vm;

                            ^^^^^^^^^
                            Java?

Quote:
>  name="tDemoButton"
> Content-Transfer-Encoding: base64
> Content-Disposition: inline;
>  filename="tDemoButton"

> IyEvdXNyL2xvY2FsL2Jpbi9wZXJsCnVzZSBUazsKdXNlIERlbW9CdXR0b247CgpteSAkbXc9
> TWFpbldpbmRvdy0+bmV3KC10aXRsZT0+J0RFTU9CVVRUT04nKTsKCiMKIyBUaGlzIHdvcmtz
> CiMgbXkgJGRiPSRtdy0+RGVtb0J1dHRvbigtdGV4dD0+J1BSRVNTJywtY29tbWFuZD0+c3Vi
> eyBwcmludCAiREREXG4ifSApLT5wYWNrKCk7CiMgYnV0IHRoaXMgZG9lc24ndApteSAkZGI9
> JG13LT5EZW1vQnV0dG9uKC10ZXh0PT4nRGVtbycpLT5wYWNrKCk7Cm15ICRiPSRtdy0+QnV0
> dG9uKC10ZXh0PT4nUHJlc3MnLC1jb21tYW5kPT5zdWJ7IHByaW50ICJCQkJcbiJ9ICktPnBh
> Y2soKTsKCk1haW5Mb29wOwoK
> --------------050002060606050806030103--

Regards,
        Slaven

--

need xpm or ppm output from GD?
        http://search.cpan.org/search?mode=module&query=GD::Convert



Thu, 24 Mar 2005 18:13:47 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Composite Widget ConfigSpecs METHOD problem

2. ConfigSpecs 'classes'?

3. Question: Populate and COnfigSpecs/METHOD

4. ConfigSpecs and METHOD

5. ConfigSpecs and METHOD

6. ConfigSpecs

7. Tk402.000+ and new ConfigSpecs report.

8. Populate and ConfigSpecs

9. ConfigSpecs question

10. Turning callback interface into pull interface

11. C-created Perl objects with callbacks and DESTROY

12. XSUB Callbacks

 

 
Powered by phpBB® Forum Software