RaoulW Posted November 1, 2020 Share Posted November 1, 2020 Hi, Newbie user and looks great! I'm tring to update a TUniTreeMenu inside the event handler of a menu item. When I do this, the entire menu is ducplicated. I have tried: UniTreeMenu1.BeginUpdate; UniTreeMenu1.SourceMenu := nil; MyMenuItems.Clear; etc. MyMenuItems is a sub menu. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 1, 2020 Share Posted November 1, 2020 7 hours ago, RaoulW said: I'm tring to update a TUniTreeMenu inside the event handler of a menu item. When I do this, the entire menu is ducplicated. I have tried: UniTreeMenu1.BeginUpdate; UniTreeMenu1.SourceMenu := nil; MyMenuItems.Clear; etc. MyMenuItems is a sub menu. Hello, Please provide more details. Quote Link to comment Share on other sites More sharing options...
RaoulW Posted November 2, 2020 Author Share Posted November 2, 2020 Hi, See the attached sample project. After clicking, you'll see that at the bottom the whole menu is duplicated from the Home button down again. UniMenuTest.zip Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 2, 2020 Share Posted November 2, 2020 Hi, We will check your testcase. Quote Link to comment Share on other sites More sharing options...
RaoulW Posted November 5, 2020 Author Share Posted November 5, 2020 Hi, Any update on this? Quote Link to comment Share on other sites More sharing options...
RaoulW Posted November 11, 2020 Author Share Posted November 11, 2020 ?? Quote Link to comment Share on other sites More sharing options...
alfr Posted November 11, 2020 Share Posted November 11, 2020 Hi, I believe there is some gap or at least handled different with the html menu compared to native delphi. If you skip the following 4 lines (2 before your updates and 2 after your updates) the menu is updated correct. So changes are not updated correctly on the UniTreeMenu1 when using .BeginUpdate / .EndUpdate (So at least these lines mustn't be used for the menu to be updated correctly. UniTreeMenu1.BeginUpdate; UniTreeMenu1.SourceMenu := nil; // All other code... UniTreeMenu1.EndUpdate; UniTreeMenu1.SourceMenu := UniMenuItems1; Quote Link to comment Share on other sites More sharing options...
RaoulW Posted November 12, 2020 Author Share Posted November 12, 2020 Hi, Thanks for the response. When I remove those 4 lines, the menu is not refreshed when I add items. I need to preforma a simpel task, add a menuitem to the menu and refresh it. Thanks, Quote Link to comment Share on other sites More sharing options...
alfr Posted November 12, 2020 Share Posted November 12, 2020 Unfortunately it seems to have some bugs - so believe the UniGui team need to respond what the plan is around it. see similair / other problems reported below with some suggestions... Quote Link to comment Share on other sites More sharing options...
RaoulW Posted November 13, 2020 Author Share Posted November 13, 2020 Hmm ok, the frist two deal with hiding existing items and not adding them. I tried the last option but that removes all menu items. I only need to remove or add to a certain subment. No idea how to do that in JS... Thanks, Quote Link to comment Share on other sites More sharing options...
lcolombo Posted November 16, 2020 Share Posted November 16, 2020 Hi, You must delete each item: I := UniTreeMenu1.Items.Count-1; while(I > 0) do begin UniTreeMenu1.Items.Delete(UniTreeMenu1.Items.Item[I]); I := UniTreeMenu1.Items.Count-1; If(I = 0)then UniTreeMenu1.Items.Delete(UniTreeMenu1.Items.Item[0]); end; Quote Link to comment Share on other sites More sharing options...
RaoulW Posted November 17, 2020 Author Share Posted November 17, 2020 Hi, Thanks for the help. Unfortunately it does not help. I have to re-create a submenu so I changed your example to: for i := SubMenu.Count-1 downto 0 do begin for j := SubMenu[i].Count-1 downto 0 do SubMenu[i].Delete(j); SubMenu.Delete(i); end; But that results in the entire menu dissapearing. Using the BeginUpdate and/or SourceMenu := 0 has no effect, the menu stays blank. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.