Logrus
Topic Author
Posts: 23
Joined: 22 Jul 2015, 12:16

Create ContextMenu programmatically

14 Mar 2021, 07:08

Hi
auto image = MakePtr<Image>();
image->SetSource(MakePtr<TextureSource>(LoadTexture(path)));

auto menu = MakePtr<ContextMenu>();
auto item = MakePtr<MenuItem>();
item->SetHeader("Hello");
item->SetText(MakePtr<TextBlock>("World"));
menu->GetItems()->Add(item);

image->SetContextMenu(menu);

image->MouseRightButtonDown() += [](BaseComponent* sender, const MouseButtonEventArgs& e) {
	auto image = (Image*)sender;
	auto menu = image->GetContextMenu();
	menu->SetIsOpen(true);
	menu->setIsEnabled(true);
	menu->SetVisibility(Visibility_Visible);
};
ContextMenu is not displayed.
 
Logrus
Topic Author
Posts: 23
Joined: 22 Jul 2015, 12:16

Re: Create ContextMenu programmatically

15 Mar 2021, 08:57

closed

in the parent element on the right button the mouse was captured.
 
User avatar
sfernandez
Site Admin
Posts: 2323
Joined: 22 Dec 2011, 19:20

Re: Create ContextMenu programmatically

15 Mar 2021, 10:26

Thanks for the update.

Who is online

Users browsing this forum: No registered users and 1 guest