Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

ContextMenuItem.Icon not Show

Post Reply
tonzi
Posts: 7
Joined: Mon May 27, 2024 9:31 am

ContextMenuItem.Icon not Show

Post by tonzi »

Hi,

I try to Add ContextMenuItem.Icon, but not show icon, missing what? pls, check it, thks.

Code: Select all

 
 TempArgs := TCoreWebView2ContextMenuRequestedEventArgs.Create(aArgs);
  TempCollection := TCoreWebView2ContextMenuItemCollection.Create
    (TempArgs.MenuItems);

  try
    if not(Assigned(FExecJSMenuItem)) then
    begin
      Ms := TMemoryStream.Create;
      Ms.LoadFromFile('xx.svg');
      Ms.Position := 0;
      StreamAdapter := TStreamAdapter.Create(Ms, soOwned);

      if WVBrowser1.CoreWebView2Environment.CreateContextMenuItem('YYY',
        StreamAdapter, COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_COMMAND,
        TempMenuItemItf) then
        try
          FExecJSMenuItem := TCoreWebView2ContextMenuItem.Create
            (TempMenuItemItf);
          FExecJSCommandID := FExecJSMenuItem.CommandId;
          FExecJSMenuItem.AddAllBrowserEvents(WVBrowser1);
        finally
          TempMenuItemItf := nil;
        end;
    end;

    if Assigned(FExecJSMenuItem) and FExecJSMenuItem.Initialized then
    begin
      TempCollection.InsertValueAtIndex(TempCollection.Count,
        FExecJSMenuItem.BaseIntf);
    end;
  finally
    FreeAndNil(TempCollection);
    FreeAndNil(TempArgs);
  end;
  
User avatar
salvadordf
Posts: 4620
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: ContextMenuItem.Icon not Show

Post by salvadordf »

Hi,

The WebView2 feedback repository has an open issue about the context menu icons not showing up :
https://github.com/MicrosoftEdge/WebView2Feedback/issues/2562

All the official code samples use a null/nil value for the aIconStream parameter.
tonzi
Posts: 7
Joined: Mon May 27, 2024 9:31 am

Re: ContextMenuItem.Icon not Show

Post by tonzi »

Hi,

if Change xx.svg to binary xx.jpg, Test it OK. :) thks
Post Reply