Closed 1sra3l closed 3 years ago
I made sure it worked completely before push
this time :rofl:
Thanks for the PR :)
Thanks!
One thing I have been noticing in my recent exploratory test is that emit does not work in the way I'd expect (signals seem to be missed, or delayed). The trade-off using a callback is no way to impact the original. Example issue:
let thing = MyThing::new();
let mut cb_thing = thing.clone();
ui.button1.set_callback( move|_| {
// manipulate cb_thing
});
// reassign thing = cb_thing.clone(); does not work obviously
let mut cb_thing = thing.clone();
ui.button2.set_callback( move|_| {
// manipulate cb_thing
});
//thing is the original.
what is the proper/fastest way to interact between widgets and functions? C++ is very different, so I am having to unlearn/relearn how to use FLTK as I go
The fastest way is thru using callbacks. Currently sending messages allocates and locks, sends the message then unlocks.
FLTK doesn’t offer access to the message queue, recv() basically gives access to the last message only. This becomes apparent mostly when you send messages in the handle() method. The limitation in fltk channels can be mitigated by using a different channel (crossbeam-channel). Related discussions: https://github.com/fltk-rs/fltk-rs/discussions/978
This is a simple text viewer with "toolbar" buttons that emit
Action
to be received. Very basic example but also includes the group{.begin(), .end()} which may get scraped in :smile_cat: as well as a basic TextEditor (no saving, no menus, etc....)