Passing an event up to a container

  1. 2 months ago

    Peter L

    Jun 10 Pre-Release Testers, Xojo Pro

    I'm trying to produce a container control that will allow entry of an angle (or a time interval) in either DMS (HMS) or decimal degrees (hours).

    The image below shows the control in question. It contains 3 container controls (one for each of D, M, and S) each with a slider and a text field so changing either the slider or the text field will update the other. The outer container also has a text field (on the right) that is to display the angle in decimal degrees.

    My question is, how do I get changes in each of the internal (slider/textfield) containers to immediately change the value in the outer decimal degrees field?

    -image-

  2. Antonio R

    Jun 10 Pre-Release Testers, Xojo Pro Europe (Italy)

    Define an event in your container control (valueChanged for instance)
    and raise it when the sliders change their value or the text field or raise it for every situation you need.

    for a better solution you can create a computed property in the container control, change the value for every case you need, then in the Set function raise the event. the "reader" of the event will read this value (or you can read it when ever you need)

  3. Peter L

    Jun 10 Pre-Release Testers, Xojo Pro
    Edited 2 months ago

    Antonio,

    Thanks for your reply. The problem I am having is that I have a container within a container and I don't know how to pass an event from the inner container to the outer container. Is there something I should be researching to get a handle on this?

    In other words, how can the outer container know that there was been a change in one of the controls of the inner container?

    Peter

  4. Antonio R

    Jun 10 Pre-Release Testers, Xojo Pro Europe (Italy)

    you can replicate the same thing for every container involved.

    In the sub container define the event and raise it when you need.

    In the "super" container reply to the new define event of your sub container.

    It the "super" container is a sub of a another container, then define an event and as "reply" of the sub container event raise your event.

  5. Peter L

    Jun 10 Pre-Release Testers, Xojo Pro

    Antonio,

    I don't fully understand what you are saying but you have given me something to research and that was what I was hoping for. I'm not sure what you mean by:

    In the "super" container reply to the new define event of your sub container.

    but I will look into defining and raising events.

    Many thanks.

    Regards,
    Peter

  6. Andrew L

    Jun 10 San Francisco, CA, USA

    @Peter L The problem I am having is that I have a container within a container and I don't know how to pass an event from the inner container to the outer container.

    Add an event definition to the inner container (the class itself, not the one on the outer container.) Then go to the outer container and add the corresponding event handler to the inner container used there. Switch back to the inner container class and you can raise the event by calling it like a method (e.g. MyEvent(Someparam, Someotherparam).)

  7. Julian S

    Jun 10 Pre-Release Testers, Xojo Pro UK

    Here you go Peter: https://www.dropbox.com/s/2m4n1ujwf9cufqo/EventFromContainerContainer.xojo_binary_project?dl=1

  8. Peter L

    Jun 11 Pre-Release Testers, Xojo Pro

    Thanks to everyone for your replies. Very helpful, I've got my head around it now.

or Sign Up to reply!