MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
425 stars 51 forks source link

Context menu - Separator #2370

Open ajtruckle opened 2 years ago

ajtruckle commented 2 years ago

So I am trying to insert a separator. So far I tried:

CHECK_FAILURE(webviewEnvironment->CreateContextMenuItem(
    L"", nullptr,
    COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SEPARATOR,
    &m_separatorContextSubMenuItem));

CHECK_FAILURE(items->InsertValueAtIndex(
    itemsCount, m_separatorContextSubMenuItem.get()));

But I see no separator?

For me personally, could we have a sample that shows us using our own menu template? All the samples seem to "build" a menu. I already have a menu. Although it was designed for IE so thinks like "View Source" will need changing in some way.

But I digress. What is the right way to add a separator to the custom context menu? Eg, just before "New Sub Menu" in the sample code.

AB#39180680

ajtruckle commented 2 years ago

If I comment out all of the sample code and just add a separator it is OK:

CHECK_FAILURE(webviewEnvironment->CreateContextMenuItem(
    L"", nullptr,
    COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SEPARATOR,
    &m_separatorContextSubMenuItem));

CHECK_FAILURE(items->InsertValueAtIndex(
    itemsCount, m_separatorContextSubMenuItem.get()));
itemsCount++;

But:

yildirimcagri-msft commented 2 years ago

You can get the updated count and use that value to insert at the end. However, we will look into why you cannot add the same separator object twice. Thanks!

ajtruckle commented 1 year ago

@yildirimcagri I just wanted to add that there is the related issue where all existing separators have the same name value of other. Ideally they should be distinct so we don't have to manually keep a count.

ajtruckle commented 3 months ago

@yildirimcagri-msft Hi! Any progress with this? Been a couple of years now.