|We recently encountered a problem with our generic menu routines. They
are designed to figure out which object has focus at any given time and automatically act
upon the object with focus. This allows our developers to place many datawindows on the
same window and when the user clicks new row we know what to tell the business entity to
create a new row for.
We discovered a problem where users would click twice on a tab
folder tab thus setting focus to the tab folder. Then they would press new row and our
automatic routine would not know which object to talk to the business entity about. Thus
no new row appeared and the user was confused.
Thus we created a service which could be plugged into the tab folder object so that
when the tab gets focus it figures out which control is the first control in the tab
sequence and sets focus there. Note we Post the SetFocus function otherwise
PowerBuilder messes up the redrawing of the tab object :-(.
This code has been modified so that it can be put in the tab control itself. It is also
a good example of walking the tab folder control array.
// Set focus to the object with the lowest tab order
Integer li_Max, li_I, li_Order = 9999
DragObject ldo_Focus, ldo_Temp
IF UpperBound( this.Control ) < SelectedTab THEN RETURN
li_Max = UpperBound( this.Control[ SelectedTab ].Control )
FOR li_I = 1 TO li_Max
ldo_Temp = this.Control[ selectedtab ].Control[ li_I ]
IF ldo_Temp.taborder < li_Order AND ldo_Temp.taborder > 0 THEN
li_Order = ldo_Temp.taborder
ldo_Focus = ldo_Temp
IF IsValid( ldo_Focus ) THEN
// Post this otherwise PB gets a redraw problem
// on the tab :(
ldo_Focus.FUNCTION POST SetFocus()