Creating non-generic delegate when there is generic one
Posted: June 8th, 2013, 6:46 pm
Hello
I'm working on porting a php-gtk application to phalanger/gtk-sharp. Currently I'm stuck on the following problem:
There is an event (Gtk.MenuItem.Activated) that only accepts System.EventHandler delegates (but not System.EventHandler<TEventArgs> variety). When I try to create a delegate based on http://wiki.php-compiler.net/Code_Sampl ... chronously sample, it creates generic version:
So the question is: how do I create System\EventHandler instead of System\EventHandler<:T:> ?
PS: I also tried to inherit System\EventHandler in my own class, but unfortunately it's marked final and thus non-extendable.
I'm working on porting a php-gtk application to phalanger/gtk-sharp. Currently I'm stuck on the following problem:
There is an event (Gtk.MenuItem.Activated) that only accepts System.EventHandler delegates (but not System.EventHandler<TEventArgs> variety). When I try to create a delegate based on http://wiki.php-compiler.net/Code_Sampl ... chronously sample, it creates generic version:
- Code: Select all
$h = new \System\EventHandler(function() {});
\var_dump($h);
$item = $this->ui->GetWidget('quit_menu_item');
\var_dump(\get_class($item), $item->Activated);
$item->Activated->Add($h);
- Code: Select all
object(System\EventHandler<:System\Object:>)#1051914240 (2) {
["Method"]=>
{Void <^DelegateStub>(PHP.Core.Reflection.DObject, System.Object, System.Object)}
["Target"]=>
{object}
}
string(17) "Gtk\ImageMenuItem"
object(EventClass<:System\EventHandler:>)#380650752 (0) {
}
Error: Argument 'handler' must be of type 'System\EventHandler'.
So the question is: how do I create System\EventHandler instead of System\EventHandler<:T:> ?
PS: I also tried to inherit System\EventHandler in my own class, but unfortunately it's marked final and thus non-extendable.