How to customize the context menu for a custom widget? #751
Unanswered
SolenOchHavet
asked this question in
Q&A
Replies: 1 comment
-
After looking closer at some examples, I finally got it! I was able to solve it in my // Make your drawing here
giu.Layout{
// Required to be able to use context menu. The size must obviously cover the entire widget;
// in my case it was the entire screen hence the -1, -1.
giu.InvisibleButton().Size(-1, -1),
// Build the menu here
giu.ContextMenu().Layout( ),
}.Build() // And don't forget run this function |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm still learning the concepts of giu, so it's obviously something I'm missing or misunderstood. I have created a custom widget that uses the canvas to draw different images. And then the user can pan and zoom with his/her mouse. What I can't figure out is that I want to have a different context menu depending on if the user right-clicks an image or the background. I'm able to figure out what the user clicks on in my Build() function, but I have no way to raise a context menu from this location.
The closest thing I have been able to do so far is to have an InvisibleButton stretched across the entire widget and then add a context menu after my widget in the render loop:
In some locations I have seen this pattern:
But that doesn't look like something that instantly builds and appears on the screen.
Any guidance is appreciated! :)
Beta Was this translation helpful? Give feedback.
All reactions