Function gtk_test::enter_key

source ·
pub fn enter_key<W: Clone + IsA<Object> + IsA<Widget> + WidgetExt>(
    widget: &W,
    key: Key
)
Expand description

Send a key event to the given widget.

Warning!

Please note that the enter-key event will “fail” if the window isn’t on top of all other windows (this is a common issue on OSX). Don’t forget to bring the button’s window on top by using:

window.activate_focus();

Example:

#[macro_use]
extern crate gtk_test;

use gtk_test::gtk::{Entry, prelude::EntryExt};

gtk_test::gtk::init().expect("GTK init failed");
let entry = Entry::new();
entry.connect_preedit_changed(|_, _| {
    println!("key entered");
});
gtk_test::enter_key(&entry, gtk_test::gdk::keys::constants::Agrave);