I have a table box displayed within a tab box. When I make a selection in the table box I would like to switch to a different tab. However, it seems that when the event handler for the row selection finishes, it returns focus to the original tab.
Here is some illustrative code. Once a row is selected in the table box I want to set the focus to the 2nd tab. I've put Wait(2) in the code to show the switch of focus does occur - but the focus switches back when the function finishes.
Names Default To Here( 1 );
New Window( "Mountains",
tab = Tab Box(
"Tab1",
tb = Table Box(
String Col Box( "Mountain",
{"K2", "Delphi", "Kilimanjaro", "Grand Teton"}
),
Number Col Box( "Elevation (meters)",
{8611, 681, 5895, 4199}
),
Plot Col Box( "", {8611, 681, 5895, 4199} )
),
"Tab2",
txt = Text Box("")
)
);
tb << Set Selectable Rows();
tb << set row change function(
Function( {this},
Wait(0.3); // wait just long enough to show the selection
txt <<Set Text("Selection=" || Char(this << get selected rows) );
tab << Set Selected(2);
Wait(2); // tab gets selected ... but only for 2 seconds
)
);