On parent form WIDGET_TESTER I have a subform of instance name ‘formDate’. The name of the subform is “DateEntry”. I wish to have a BOUND VARIABLE of type DATE on this instance.
if the DATE is a process variable, it works swell. **** if it is based on the parent form’s FORM. (such as Form.thisDate) this does not work. ***** — MY CONUNDRUM! in particular: In the Subform’s form method, in the ‘On Bound Variable Change’ handler, the subform needs to get the bound variable’s pointer. This is done either with OBJECT Get Pointer(Object subform container) or (as in 4D’s widget collection source code) Self(Object subform container) is used. This is successful if the bound variable is a process variable. It does not work if it is Form.thisDate (which is a date; set to ‘current date’ for example). The Form.thisDate is defined in the parent’s ON LOAD handler, so it should exist by the time the instance ‘formDate’ is configured. Sure seems to work for process variables! I am not yet an expert on subform creation, as I have mostly avoided them in the past. However, I can see the wisdom of creating widgets to put in my own object library. But they need to be able to work in the context of a parent’s Form. object to be of use for me, as I use this extensively rather than process variables. thanks for any suggestions, Chris Belanger —————— Detailed explanation (if needed or interested) I’ve been working on making some widgets, inspired by 4D’s collection. My question is about rewriting the DateEntry widget. After I do that, I intend to do some other widgets. When I looked at the 4D source code, I saw it still uses a lot of code, methods, process vars, etc. So I made a ‘DateEntry’ widget (in my custom component) that employs Form. objects / variables instead. It works very nicely, with a great simplification of code and elimination of process methods and process vars. When the widget is put (as a subform) on a Parent Form, the Bound Variable is of type DATE. It works as expected whenever it is a PROCESS VARIABLE. However, if the bound variable is Form.theDate (a DATE ‘variable’), then it fails. WHAT I AM DOING: In the widget’s form: In the FORM EVENT ‘On Bound Variable Change’ — I configure what I need for the widget to process the bound variable. This involves creating some Form. vars to manage the input. • so in this situation, it is very simple. Case of :(Form event = On Bound Variable Change) // use the value of the Bound Variable (a Date) to configure the components DAY, MONTH, YEAR $theVarPtr:=OBJECT Get Pointer (Object subform container) // this is the pointer to the bound variable, for instance ->processVar Form.theDate := $theVarPtr-> // copy the contents of the subform contain to our widget’s ‘date’ so we can manipulate it without changing the bound variable until we are ready (On Deactivate) // Break it into its component pieces: DAY, MONTH, YEAR, for the widget Form.theDay := Day of(Form.theDate) Form.theMonth:= Month of(Form.theDate) Form.theYear:=Year of(Form.theDate) —— OBJECT Get Pointer ( Object subform container) works as expected when the Parent Form’s bound variable is of type DATE and is a process Variable. Self(Object subform container) also gets the Parent Form’s bound variable (this is what the 4D widget uses; however, Self is always Nil in this situation) ** however ** it does not work when the bound variable is a Date that is define in the Parent’s Form. context. I.E. if the bound variable is Form.simpleDate this does not work. If it is Form.entity.simpleDate this also does not work. ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

