Find next widget in tab order

jdpjamesp

ProgressTalk.com Moderator
Staff member
Does anyone have some code handy to find the next widget in the tab order on a screen? OE10.1B. We programatically hide certain widgets on the screen and therefore we need to be able to establish which widget to apply entry to when manually applying entry in the code. If that makes sense.

here's a snippet that I know doesn't work... it just seems to find the first widget on the screen.

Code:
      FocusLoop:
      REPEAT WHILE VALID-HANDLE(pvFocusHandle):
        IF  pvFocusHandle:TYPE NE "WINDOW" AND 
            pvFocusHandle:TYPE NE "FRAME"  AND 
            pvFocusHandle:TYPE NE "DIALOG-BOX" AND
            pvFocusHandle:TYPE NE "FIELD-GROUP" THEN
        DO:
          IF pvFocusHandle:TYPE NE "RECTANGLE" AND 
            pvFocusHandle:TYPE NE "MENU-ITEM" AND 
            pvFocusHandle:TYPE NE "MENU" AND 
            pvFocusHandle:TYPE NE "TEXT" AND 
            pvFocusHandle:TYPE NE "LITERAL" AND 
            pvFocusHandle:HELP NE "HIDDEN" AND 
            pvFocusHandle:SENSITIVE        AND
            pvFocusHandle:VISIBLE          THEN
          DO:
            APPLY "ENTRY" TO pvFocusHandle.
            LEAVE FocusLoop.
          END.
          ELSE
            pvFocusHandle = pvFocusHandle:NEXT-SIBLING NO-ERROR.
        END.
        ELSE
          pvFocusHandle = pvFocusHandle:FIRST-CHILD NO-ERROR.
      END.
 
The above code seems to work in a noddy window running on its own, but for our application, where you have a number of screens open at a time, it seems to get really confused, and always ends up placing focus in the first widget in the tab order. What is the error of my ways?
 
Nope I'm not. And it's not needed in a dummy piece of code. The problem's more complex than that it seems. It's seemingly to do with field groups. Or something like that. Very confusing though.
 
I'm going to try a different solution today - we already essentially have a tt with all the widgets on a screen in it - I can therefore just trawl through that and work out the next object. Should be a lot easier than walking the widget tree again!
 
Back
Top