Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread AutoOrder of Tabs
Thu, May 16 2019 3:54 PMPermanent Link

erickengelke

Avatar

I'd love a feature button to automatically reorder tabs in a EWB form based on screen location of the dev. env..

Why?  Clients constantly have you move Elements around a form, and the tab order gets so messed up, it's a pain to redo all the tabs manually.

Since I can't wait for this, I wrote an ugly ewb function which reorders automatically at form OnShow() time.  This is not an example of how to code, but it does appear to work adequately and took less time to write than fixing my form manually.  I call AutoOrder( Panel1 ) to automatically reorder all tabs on panel1.


// Support function. SpecialIntStr makes integers of constant length by zero padding them
const
 SOMEZEROS  = '0000000';

function SpecialIntStr( x : integer ):string;
begin
 result := IntToStr( x );
 result := Copy(SOMEZEROS,1,Length(SOMEZEROS)-Length(result ))+result;
end;

procedure AutoOrder( x : TControl );
var
  ss : array of string;
  i : integer;
  sl : TStringList;
  c : TControl;
  j : integer;
  k : integer;
  el : TEdit;
begin

  sl := TStringList.Create;
  sl.Sorted := True;           

  // build a sorted list of ypos.xpos:control#
  for i := 0 to x.ControlCount - 1 do begin
     try
       c :=  x.Controls[i];
       sl.Add( SpecialIntStr( c.Top ) + '.' + SpecialIntStr( c.Left ) + ':' + IntToStr(i) );
     except on E:Exception
       do window.alert('ERROR sorting controls: ' + E.message );
     end;
  end;
  // list is now complete and sorted
  k := 0;
  for i := 0 to x.controlcount - 1 do begin
     ss := split( sl[i] , ':' );
     j := StrToInt( ss[1] );

     try
       c := x.Controls[j];
       if c.CanFocus then begin
         el := TEdit( variant(c) );  // THIS LINE IS GROTESQUE
         el.TabOrder := k;
         inc(k);
       end;
     except on E:Exception
       do window.alert('ERROR sorting controls post: ' + E.message );
     end;
  end;
  sl.Free;
end;
EWB Programming Books and Component Library
http://www.erickengelke.com
Mon, May 20 2019 12:05 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Erick,

<< I'd love a feature button to automatically reorder tabs in a EWB form based on screen location of the dev. env.. >>

I'm not quite sure what you're asking for here.  Are we talking about a TPagePanel control, and are you re-ordering the *tabs*, or some other controls that are *on* the pages ?

EWB allows you to use the component navigator to re-order controls based upon their layout order or tab order using drag and drop, so that may help.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, May 21 2019 1:03 PMPermanent Link

erickengelke

Avatar

Tim Young [Elevate Software] wrote:

Erick,

<< I'd love a feature button to automatically reorder tabs in a EWB form based on screen location of the dev. env.. >>

> I'm not quite sure what you're asking for here.  Are we talking about a TPagePanel control, and are you
> re-ordering the *tabs*, or some other controls that are *on* the pages ?

>EWB allows you to use the component navigator to re-order controls based upon their layout order or tab order >using drag and drop, so that may help.

First, to be clear, this is for forms that don't use responsive design.

The Tab reordering button I've found lets you move the order of tabs, but it's painful when there are like a hundred controls on the page.

My suggestion, and the sample code, would make a stab at the ordering all the tabs automatically based on Y:X position on the screen, which read left to right, top to bottom, i.e the way we read.  

It'd be nice if there was one button you could hit that made such an ordering, then I could fine tune just the few outliers to make it perfect.
EWB Programming Books and Component Library
http://www.erickengelke.com
Sat, May 25 2019 4:01 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Erick,

<< The Tab reordering button I've found lets you move the order of tabs, but it's painful when there are like a hundred controls on the page. >>

The EWB 3 component navigator will help in this regard.  It allows you to re-order controls *within* container controls so that you only need to move around what is in a given container control node of the component tree.  And, again, this is drag-and-drop, so it's pretty easy to get the pages where you need them.

Tim Young
Elevate Software
www.elevatesoft.com
Image