Here is an example of using H Splitter Box()
and Lineup Box()
to do this. Note that this also scopes everything into an anonymous namespace to prevent cross-talk if multiple windows are opened at the same time from this script.
Names Default to Here( 1 );
self = New Namespace();
self:notReadyTablesText = "Need to join tables";
self:readyTableText = "I have the table";
self:selectorOptions = Eval List( {self:notReadyTablesText, self:readyTableText} );
Eval( Eval Expr(
self:button generator = Function( {title, callback},
{Default Local},
self = Namespace( Expr( self << Get Name ) );
Eval( Parse( Eval Insert( JSL Quote(
box = Button Box( title, <<Set Function(
Function( {this},
{Default Local},
self = Namespace( "^self << Get Name^" );
Eval( Parse( "self:^callback^" ) )
)
) ) ) );
) );
box
);
New Window( "test",
<<On Close(
self = Namespace( Expr( self << Get Name() ) );
self << Remove( self << Get Keys );
Delete Namespaces( Force( 1 ), self )
)
,
H Splitter box(
Lineup Box( N Col( 1 ), Spacing( 0 ),
Spacer Box( <<Set Auto Stretching( 1, 0 ) )
,
self:readyTableSelector = Combo Box(
self:selectorOptions,
<<Set Function( Function( {this},
{Default Local},
self = Namespace( Expr( self << Get Name ) );
self:handle selector choice;
) )
)
,
self:not ready tables = If Box( 1,
Lineup Box( N Col( 1 ), Spacing( 0 ),
Spacer Box( <<Set Auto Stretching( 1, 0 ) )
,
self:button generator( "Table 1", "open button( this )" )
,
self:button generator( "Table 2", "open button( this )" )
,
self:button generator( "Join Tables", "handle join" )
)
)
,
self:ready tables = If Box( 0,
Lineup Box( N Col( 1 ), Spacing( 0 ),
Spacer Box( <<Set Auto Stretching( 1, 0 ) )
,
self:button generator( "Load Tables", "load tables" )
)
)
)
,
Spacer Box( <<Set Auto Stretching( 1, 0 ) )
,
<<Set Sizes( {0.01, 0.99} )
)
);
self:handle selector choice = Function( {},
{Default Local},
self = Namespace( Expr( self << Get Name() ) );
selector = self:readyTableSelector << Get Selected;
If(
selector == self:notReadyTablesText,
self:notReadyTables << Set( 1 );
self:readyTables << Set( 0 );,
selector == self:readyTableText,
self:notReadyTables << Set( 0 );
self:readyTables << Set( 1 );
)
);
self:open button = Function( {this},
{Default Local},
self = Namespace( Expr( self << Get Name() ) );
Print( "Open table '" || (this << Get Button Name) || "'" );
);
self:handle join = Function( {},
Print( "Not Implemented" )
);
self:load tables = Function( {},
Print( "Not Implemented" )
);
self << Get Name
) );
Jordan