christolliday / limn

Experimental cross platform GUI library
Other
404 stars 19 forks source link

External event source #25

Closed wendivoid closed 6 years ago

wendivoid commented 6 years ago

In my application i need to be able to read events from a std::process::ChildStdout. I have accomplished this for my use case by modifying the source of App, but i feel like there should be an easier way to do this than having to maintain a copy of the source. Maybe a function like pub fn external(&mut self, func: FnMut(&mut Ui)) could be added to App, that runs once every frame. But i'm not sure what the actual signature would be.

christolliday commented 6 years ago

I think what you are describing can be achieved using a second thread to read from std::process::ChildStdout and then sending events to the main thread using event_global, this is how the clock example sends clock ticks.

You can add event handlers that run every frame by listening for the FrameEvent that was recently added but I'm not sure if that solves your problem.

wendivoid commented 6 years ago

Ok looking into FrameEvent it appears to be just what i need, Thank you!