In both cases of your code, the dialogs do not yet have associated Views because they have not been shown yet, so get-view is returning null.

I think you should follow Friedger's advice which was "Note that dialog.show will create a new view whenever it is shown. I would write a subclass that has one instance of View that is always reused when the dialog should be shown."

takanobu maekawa wrote:

Hi gurus,

If you need to get to the view created by dialog.show, you can use
code like this:

    {on ae:AttachEvent at v:Visual do
        {dump {v.get-view}} || Here is where you can access the view
    }

A good place for it might be the outermost object in the dialog,
but it could be on almost any object shown in the dialog.

  - Mike


I have been trying according to your advise, but I can't.
I'm getting confused.

the following is the code I used for trying.
Please tell me what is wrong to get the view class of Dialog.
Or, after all, is it impossible with Dialog as Friedger said?
------------------------------------------------------------------

||
||the first class I had expected to run with no problem
||(but it doesn't run with Dialog's view)
||
{define-class public AAA
  field private v:#View

  || need a View class
  || expects to get the View class from Dialog with {Dialog.get-view}
  ||
  {constructor public {default v:#View}
    set self.v = v
  }

  {method public {show}
    {self.v.show}
  }
}


||
||the second class that I tried according to Mike's advise.
||
{define-class public BBB
  field private v:#View
  {constructor public {default v:#Visual}

    {v.add-event-handler
      {on ae:AttachEvent at vs:Visual do
        set self.v = {vs.get-view}
      }
    }
  }

  {method public {show}
    {self.v.show}
  }
}


{do
  let d:Dialog = {Dialog}
  let v:VBox = {VBox "I am one."}
  {d.add v}

  let d2:Dialog = {Dialog}
  let v2:VBox = {VBox "I am here."}
  {d2.add v2}

  let a:AAA = {AAA {d.get-view}}
  let b:BBB = {BBB d2}

  ||the both bellow lines cause NullDereferenceException
  {a.show}
  {b.show}
}
------------------------------------------------------------------

Regards.

--Takanobu Maekawa


*******************************************
To unsubscribe from this list, send a mail to:
mailto:[EMAIL PROTECTED]
To contact a human list administrator, send a mail to:
mailto:[EMAIL PROTECTED]
To recieve a list of other options for this list, send a mail to:
mailto:[EMAIL PROTECTED]


*******************************************
To unsubscribe from this list, send a mail to:
mailto:[EMAIL PROTECTED]
To contact a human list administrator, send a mail to:
mailto:[EMAIL PROTECTED]
To recieve a list of other options for this list, send a mail to:
mailto:[EMAIL PROTECTED]

Reply via email to