OK, after LOTS of experimenting, I have now managed to set all the required fields in the gdk::EventKey struct and send a synthesized key-press event.
- gdk::Event::new(gdk::EventType::KeyPress) returns an immutable reference, so have to convert that to mutable by pointer manipulation.
- gdk::EventKey has a few setter functions, but they don’t cover most of the fields that must be set.
- Need to set a device, otherwise GTK outputs numerous warning messages; at least gdk::EventKey has a set_device(&dev) function.
- For the window field, needs a mutable pointer to the gdk_sys::GdkWindow; more pointer manipulation.
- Last but definitely not least, need to increment the ref count for the GTK object of the window, requiring more pointer manipulation on gdk_sys::GdkWindow.
If anyone is interested, I can post the code.
I’m sure there must be proper Rustic ways of doing all this (if not, there should be!) but I have not found anything to date, not helped by my newbie status as a Rust coder. Grateful for any help in that direction.