iolivia / imgui-ggez-starter

Starter projects connecting ggez and imgui in Rust.
MIT License
64 stars 8 forks source link

stop ggez from acting on clicks in imgui windows #16

Open davideps opened 4 years ago

davideps commented 4 years ago

Hi Olivia,

In your setup, ggez passes mouse behavior to imgui to process or ignore as necessary. However, can you see any way for ggez to know whether the user is clicking in an imgui window so it knows whether to process or ignore the click? For example, selecting an item in the popup also registers a click with ggez. I think ggez would need to know the location and size of all imgui windows, right?

-david

iolivia commented 4 years ago

Hey David, this is definitely a problem I've had but hadn't quite gotten around to solving. I think the fundamental issue is that the ggez input system doesn't know about imgui, so probably some custom glue code needs to be written.

One idea might be to:

  1. send the event to imgui first (the UI will likely be on top of the game so this makes sense)
  2. check io.WantMouseCapture to see if imgui already handled the event - see https://github.com/ocornut/imgui/issues/687
  3. if imgui didn't handle the event, send it to ggez
saucesaft commented 4 years ago

Hi, just stumbled on this issue and have an idea. We have the imgui wrapper function for each event, and the wrapper knows were each window is. So maybe if the mouse is under a imgui window, we could set a global variable inside of the imgui_wrapper. So now, after we pass the events to imgui, we could check if that boil is true, to proceed to ggez input logic. I could maybe help implementing this.

iolivia commented 4 years ago

sounds promising @saucesaft, feel free to create a draft PR and we can discuss 😄