How to create a callback of a method inside a Class ?

Writing and using Classes in Dyalog APL

How to create a callback of a method inside a Class ?

Postby PGilbert on Tue Mar 24, 2020 1:21 am

With the following :Namespace

Code: Select all
:Namespace Test1

      :Using System.Windows.Forms,System.Windows.Forms.dll

    ∇ Make
      :Access Public
      form←⎕NEW Form
      form.Text←'Form of Namespace Test1'
      form.add_Closing(⎕OR'FormClosingEvent')
      form.Show ⍬
    ∇

    ∇ FormClosingEvent(sender event)
      :Access Public
      sender.Text,' is closing'
    ∇

:EndNamespace


If I type Test1.Make and close the Form created I will get the expected message from the onClosing handler (Form of Namespace Test1 is closing).

Now with the following :Class that is identical to the previous :Namespace

Code: Select all
:Class Test2

:Using System.Windows.Forms,System.Windows.Forms.dll

    ∇ Make
      :Access Public
      :Implements Constructor     
      form←⎕NEW Form
      form.Text←'Form of Class Test2'
      form.add_Closing(⎕OR'FormClosingEvent')
      form.Show ⍬
    ∇

    ∇ FormClosingEvent(sender event)
      :Access Public
      sender.Text,' is closing'
    ∇

:EndClass


If I do test2 ← ⎕new Test2 and close the Form created I will get the error: Method not found FormClosingEvent.

What do I need to do for :Class callback to find the method inside the class that it was created from ?

Thanks in advance.
User avatar
PGilbert
 
Posts: 373
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Return to Object Oriented Programming

Who is online

Users browsing this forum: No registered users and 1 guest