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
It appears that the Image widget does not have a "sense" hooked up and therefore doesn't listen for button clicks.
At least, that's how it appeared after quickly comparing Image to Button implementations.
I'm not sure if this is intentional and I should wrap the image in some other container that detects clicks... or if this is indeed a bug / missing functionality.
What I'm trying to do is implement a simple Tile picker/chooser, and so I was looking to just show the image, detect clicks on it, get the mouse cursor offset into the widget, do the math, and pick the tile. I didn't see any other obvious way of doing it with the current EGUI types, so I went this route.
Thanks!
The text was updated successfully, but these errors were encountered:
When adding a widget (such as an Image) you get back an egui::Response which includes the Rect for its location. You can detect clicks on it using ui.interact as so:
let response = ui.image(...);let id = ui.make_position_id();let response = ui.interact(response.rect, id,Sense::click());if response.clicked{
...}
This should work well, but has the downside of the image looking the same regardless of the mouse hovering or clicking on it (while a regular button changes color when you interact with it). I am planning to one day add some sort of button container that adds a frame around e.g. an image so that you get that nice mouse-over effect, but I haven't gotten around to it yet.
Hello,
It appears that the
Image
widget does not have a "sense" hooked up and therefore doesn't listen for button clicks.At least, that's how it appeared after quickly comparing
Image
toButton
implementations.I'm not sure if this is intentional and I should wrap the image in some other container that detects clicks... or if this is indeed a bug / missing functionality.
What I'm trying to do is implement a simple Tile picker/chooser, and so I was looking to just show the image, detect clicks on it, get the mouse cursor offset into the widget, do the math, and pick the tile. I didn't see any other obvious way of doing it with the current EGUI types, so I went this route.
Thanks!
The text was updated successfully, but these errors were encountered: