Jump to content

"TUniTreeMenu" does not support "TUniImageList" ?


Luciano França

Recommended Posts

Attached my example that I can't show the images or set the onClick event

 

Procedure P_CopyMenuToTreeView(aMenu: TUniMenuItem; aTreeview: TUniTreeMenu);

 Procedure AddItems(anItem: TUniMenuItem; aParentNode: TUniTreeNode);
 Var node: TUniTreeNode;
  I: Integer;
 Begin
  For I := 0 To anItem.Count - 1 Do Begin
   node := aTreeview.Items.AddChild(aParentNode, anItem.Items[I].Caption);
   node.ImageIndex := anItem.Items[I].ImageIndex;
   
   // Because it does not work
    node.OnClick := anItem.Items[I].OnClick; 

   AddItems(anItem.Items[I], node);
  End;
 End;

Begin
 aTreeview.Items.Clear;

 If Assigned(aMenu) Then
  AddItems(aMenu, nil);

End;

 

ImageList TreeList.7z

Link to comment
Share on other sites

From what I saw in old posts, "TUniTreeMenu" does not support BMP or PNG, is this limitation still in force in 2023?

Will I have to use fonts with icons ?

About the event

  node.OnClick := anItem.Items[I].OnClick; 

Solution
 

procedure TForm_BuscaMainMenuHost.UniDBTreeListClick(Sender: TObject);
Var I : Integer;
Var fText: String;
begin
 if not Assigned(DBTreeList.Selected) Then
  Exit;

 fText := DBTreeList.Selected.Text;

 if trim(fText) <> EmptyStr Then
  For I := 0 to Form_MenuPrincipal.ComponentCount - 1 do
   if Form_MenuPrincipal.Components[I] is TMenuItem then Begin

    if Trim((Form_MenuPrincipal.Components[I] as TMenuItem).Caption) = Trim(fText) Then Begin
     vBuscarMenu := false;

     (Form_MenuPrincipal.Components[I] as TMenuItem).OnClick((Form_MenuPrincipal.Components[I] as TMenuItem));

     vBuscarMenu := True;
     Break;
    End;
   End;

end;

But I don't understand why it doesn't work
node.OnClick := anItem.Items[I].OnClick;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...