Page 1 of 1

ContextMenuItem.Icon not Show

Posted: Fri Dec 06, 2024 3:51 am
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;
  

Re: ContextMenuItem.Icon not Show

Posted: Mon Dec 09, 2024 3:37 pm
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.

Re: ContextMenuItem.Icon not Show

Posted: Thu Dec 12, 2024 1:27 am
by tonzi
Hi,

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