Closed buster closed 9 years ago
I check it. Thx for your report.
Also, how would i check if a key is pressed while CTRL is pressed? There is the state variable on the EventKey and i found ControlMask in gdk/enums.rs. How do i match those?
If I have time I'll check that this week-end. Let's hope @jeremyletang will take a look at it before that ! ;)
But the way, I modified is_modified by is_modifier, I'll check the rest tomorrow if I have time.
To check if CTRL is pressed while a touch is pressed, just do :
if event.state & gdk::ControlMask {
...
}
I couldn't find anything about the "real" type of is_modifier.
Would you mind showing an exmaple for the state and value? I can't seem to figure it out.. Events.rs shows the following definition:
pub struct EventKey {
pub _type : gdk::EventType,
pub window : *mut gdk::Window,
send_event : i8,
pub time : u32,
pub state : u32,
pub keyval : u32,
pub length : i32,
pub string : *mut char,
pub hardware_keycode : u16,
pub group : u8,
pub is_modifier: u32
}
The reason is that i would like to get rid of comparisons with integers as shown here: https://github.com/buster/rrun/blob/master/src/main.rs#L31 and here: https://github.com/buster/rrun/blob/master/src/main.rs#L35
gdk::EscapeKey or something like should exist no ? All the keys should have their enum value. However, we should change the keyval type from u32 to the corresponding enum's name. @jeremyletang ?
that's why i am asking, i can't seem to find the right use statement, i always get
error: unresolved name
ControlMask``
Weird. Do you get it from here ?
For example, "use rgtk::gdk::enums::modifier_type::ModifierType;" doesn't work although rustc doesn't complain about an invalid use statement (which makes me think that the use statement itself finds something).
Using EscapeKey for the keypress match returns:
/src/main.rs:32:13: 32:27 error: unresolved enum variant, struct or const `EscapeKey`
/src/main.rs:32 gdk::EscapeKey => gtk::main_quit(),
I said EscapeKey just like that... And I was totally wrong. It's more complicated than I first thought ! I don't have time now but this link seems to be a good start for you search.
Or this one ! I don't think we did bind it yet.
Take a look at the #142 PR (and I created a Key type in the #143).
Hi Guillaume, thanks for all that, but i seem to be too stupid to make use of those enums. How should the import look like?
Something like this if I'm not wrong :
use rgtk::gdk::key;
key::BackSpace
While looking at how EventKey works i was comparing https://developer.gnome.org/gdk3/stable/gdk3-Event-Structures.html#GdkEventKey with https://github.com/jeremyletang/rgtk/blob/master/src/gdk/events.rs#L204
The official doc says that this is called "is_modifier" and it's a flag if the key is a modifier, whereas the rgtk is a u32.