Closed lancerasmussen closed 2 months ago
Note: I've tried things like iterating through the list of buttons to save in a TList, then free the buttons from the toolbar, then add them back in tag order (that I set in design time) and I get a stack overflow error. Also tried making the parent nil and set back the parent and same stack overflow error.
Hello Lance, can you send me a little project for the issue so I can debug and try to resolve?
Here is a small project that has some examples where TToolbar behaves and StyledToolbar doesn't
After Removing line at 1426 from Vcl.StyledToolbar.pas RemoveControl(Control); it's seems to works...
Fixed in 3.6.2, please confirm ;-)
This is the function I wrote to try to keep the menu in order based on tag, but doesn't seem to always work. I put in the start of the data is open or closed function then iterate items I want visible or not.
procedure TfrmMenu.RearrangeToolBarButtons(ToolBar: TStyledToolBar); var I,J: Integer; TagCheck: integer; temp_menu: TStyledToolbar; Idx: integer; cap: string; begin // Store the buttons in a temporary list temp_menu := TStyledToolbar.Create(self); try // Move the menu buttons to the temp menu while ToolBar.ButtonCount > 0 do ToolBar.Buttons[0].Parent := temp_Menu;
idx := 0;
// Iterate through the tempmenu buttons in order of tag until all moved;
TagCheck := 0;
while temp_Menu.ButtonCount > 0 do begin
for I := temp_menu.ButtonCount-1 downto 0 do begin
if temp_menu.Buttons[I].Tag = TagCheck then begin
temp_menu.Buttons[I].ComponentIndex:= idx;
temp_menu.Buttons[I].Parent:= ToolBar;
cap := ToolBar.Buttons[idx].Caption;
ToolBar.Buttons[idx].Left := idx * ToolBar.Buttons[idx].Width; // Reposition
inc(Idx);
end;
end;
inc(TagCheck);
end;
finally temp_Menu.Free; end; end;
My StyledToolBar inherits from TCustomFlowPanel, so the position of the "components" inside are managed by this class. Try to write a RearrangeToolBarButtons using a TFlowPanel and TButton, to check if the StyledToolbar introduces something wrong about the button position...
Created a pull request that assigns a sort order property to the buttons in the toolbar and added a procedure for the toolbar to sort the buttons.
Added pull request that has property and then a procedure to resolve.
I have a StyledToolBar with 12 TStyledToolbarButtons.
I set the visibility of those toolbarbuttons based on if the datafile is open or not. So at the app startup, I set the visibility of 7 of them to false. On Datafile Open, change visibility to false on two of the 5 initially set to true and then the remaining to true.
The order of the buttons keeps getting jumbled around when doing this and I'm not seeing a clear way to keep or designate the index of these.
I've tried: