TOPIC: Accessing a deeply nested control?
#1469
Accessing a deeply nested control? 11 Months ago
I have a window that is defined by:

Code:


  Controls()
  {
    #(Access "logbook sort flight_at"
      title: ""
      (Vert
        (Horz
          (GroupBox 'Basic Log' (Border
            (Form
              (flight_at group: 0) Skip aircraft nl nl
              (route group: 0) nl nl
              (time_day group: 0)   (day_takeoff_count group: 1) (day_landing_count group: 2) (time_cross_country group: 3) nl nl
              (time_night group: 0) (night_takeoff_count group: 1) (night_landing_count group: 2) (time_night_cross_country group: 3)
            )
          ))
          Skip
          (GroupBox 'Misc. Times' (Border (Grid (
            (time_pic (Button '<' command: 'CopyPic'))
            (time_sic (Button '<' command: 'CopySic'))
            (time_dual (Button '<' command: 'CopyDual'))
          ))))
          Skip
          (GroupBox 'Instrument' (Border
            (Vert instrument_approach_count Skip time_instrument Skip
              time_simulated_instrument)
          ))
          Skip
          (GroupBox 'Expenses' (Border (Grid (
            (fuel_used Skip fuel_cost)
            (oil_used Skip oil_cost)
            (flight_cost Skip flight_reimbursed)
          ))))
        )
        Skip
        comments
      )
    )
  }

  On_CopyPic()
  {
  }



In the On_CopyPic() function, I want to be able to access the time_day, time_night and also time_pic. How do I go about doing that?

Jeremy
 
 
#1470
Re:Accessing a deeply nested control? 11 Months ago
Give the control and id i.e.:
Code:


...
   (time_day group: 0 id:'timeday')   (
...



Then you can get a reference to the object using
Code:

 .FindControlById('timeday')
i.e:
Code:


td= .FindControlById('timeday')

td.doSomethingWithTheObject();



Disclaimer: My memory is weak... check in container or controller class (I think) the proper method name (It could be FindControlByName perhaps.(I can't check on it I'm using Linux right now...)
 
 
Last Edit: 2009/09/21 14:53 By sanotto.
 
#1471
Re:Accessing a deeply nested control? 11 Months ago
Oh! Thanks. This has gotten much easier since my last project in Suneido. I used .Access.GetControl('time_day').

Thanks,

Jeremy