Question Access child widgets to change the properties

bazilzby

New Member
Hi there.

First of all, this is my first post here so apologies if I am doing anything that breaks community rules.

I'm trying to create a script that changes the properties of child widget (color, tooltip etc) when a certain event is used, and I want to accomplish this dynamically so that the necessary widgets that need their properties changed can be edited easily.

I've been able to do it with a simple application using this code that insert the result of a JSON file into a temp-table and loops through them assigning each widget the color every time it loops through.


DEFINE VARIABLE hHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE widgetName AS CHARACTER NO-UNDO.
DEFINE VARIABLE colourNumber AS INTEGER NO-UNDO.

FOR EACH Resultst-WidgetList:
ASSIGN
widgetName = Results-WidgetList.tt-widName /* these assignments are just getting the info */
colourNumber = INT(Results-WidgetList.tt-colour
.
hHandle = SESSION:FIRST-CHILD.
DO WHILE VALID-HANDLE(hHandle):
IF hHandle:TYPE = "FIELD-GROUP" THEN LEAVE.
hHandle = hHandle:FIRST-CHILD.
END.

hHandle = hHandle:FIRST-CHILD.
DO WHILE VALID-HANDLE(hHandle):
IF hHandle:TYPE = "FILL-IN" AND hHandle:NAME = widgetName THEN LEAVE.
hHandle = hHandle:NEXT-SIBLING.
END.

ASSIGN
hHandle:BGCOLOR = colourNumber.

END.
And it works perfectly fine.

However when I try use it in my main application in a frame that has a parent frame it only searches the parent frame for the child widgets. Is it possible to drill down to the child frames that hold the widgets I need. Or is it possible that there is another way to accomplish this that I haven't thought about?
 

TomBascom

Curmudgeon
Just like on Stackoverflow your code is probably LEAVING before it has traversed the entire widget tree.

Add a few MESSAGE statements or log each step of your process to a file or run the debugger and you will see where it is going wrong.
 
Top