Dave Moore wrote:
>> this is more clear. the New Event Model I'm trying to build will
>> pass a reference to the object that fired the event as its first
>> parameter, so this issue will be solved.
>
> that will be nice, but there is still the issue of name space.
> having to name each control in some sort of global space...ie.
>
> $MW->Button(Name => 'MyButton1');
>
> gets hard to keep track when you want to break your program into
> objects or even if it gets really big. i dont know how else you
> could do it though.

but with the New Event Model (codename 'NEM') you don't need a name
at all.

> and seeming as how the topic was event handlers, i think it would
> be cool if i could say:
>
> my $btn = $MainW->Button();
> $btn->add_handler('Click', \&some_sub);
>
> sub some_sub {
>   my ($object, $event) = @_;
> }
>
> instead of making a subroutine with Name_Click. it would clean up
> all my scripts alot. for eg cancel buttons all do the same thing.
> its easier to register a routine for your events than to declare a
> subroutine that calls a subroutine.
>
> just my humble opinion

that's exactly what the NEM stands for. right now, the synopsis is:

  $MainW->AddButton(
      -text => "Click Me",
      -pos  => [ 50, 50 ],
      -events => {
          -Click => \&some_sub,
          # or
          # -Click => "some_sub",
          # or
          # -Click => sub { print 'I got a click!'; }
      },
  );

there will be, of course, a method to add, change and remove events
after the object creation. the latest version on CVS does already
support the synopsis above; I'm having serious problems supporting
a NEM for menus :-(
if someone wants to help me with this just ring the bell...


cheers,
Aldo

__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;



Reply via email to