You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create a button that takes an arbitrary polygon as its clickable shape (as part of a radial menu). I have almost everything working, except that I can't override the default behavior of Response::clicked(), which always assumes a rectangular shape. I have accurate hit detection for the shape, and within the widget's ui function I disable the Sense::CLICK on response.sense. As long as the calling code checks response.sense.senses_click() && response.clicked() it works as expected, at least for one button with no overlaps (haven't tested that yet).
I'd really like to get a bit more control over how the clicked() function works from Response though, if possible. Has anyone gotten something like that to work?
Here's what the code to interact with it would look if it worked the way I want it to:
// Make the shape for the buttonlet btn_shape = Shape::convex_polygon(vec![(0.,0.).into(),(50.,100.).into(),(100.,0.).into()],Color32::from_rgb(100,100,100),PathStroke::new(2.0,Color32::from_rgb(255,255,255)));// Add the button as usuallet res = ui.put(Rect::from_center_size((50.,50.).into(),(100.,100.).into()),ShapeButton::new(btn_shape));// Respond to clicks. This currently works if I change that test // to include res.sense.senses_click()if res.clicked(){println!("Response: {res:#?}");println!("Clicked the triangle button");if !res.sense.senses_click(){println!("should not have gotten click");}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to create a button that takes an arbitrary polygon as its clickable shape (as part of a radial menu). I have almost everything working, except that I can't override the default behavior of
Response::clicked()
, which always assumes a rectangular shape. I have accurate hit detection for the shape, and within the widget'sui
function I disable theSense::CLICK
onresponse.sense
. As long as the calling code checksresponse.sense.senses_click() && response.clicked()
it works as expected, at least for one button with no overlaps (haven't tested that yet).I'd really like to get a bit more control over how the
clicked()
function works fromResponse
though, if possible. Has anyone gotten something like that to work?Here's what the code to interact with it would look if it worked the way I want it to:
Beta Was this translation helpful? Give feedback.
All reactions