Closed lschmierer closed 4 years ago
Yes, it's a bit unfortunate that GIR doesn't seem to have a way to identify typed bit masks here. It doesn't help that gdk_add_events
has a <type name="gint" c:type="gint"/>
(signed int) signature for its parameter, while GdkEventMask
is unsigned.
This is fixed in gir2swift version 9: bitfields are no longer a typealias of the underlying C enum. Instead, the Swift type is now an OptionSet
whose rawValue can be initialised from the C type. This way, you can now do something like
widget.add(events: .buttonPressMask)
// or:
widget.add(events: [.keyPressMask, .buttonPressMask])
This is a source breaking change for any code that assumes that the C and Swift types are the same (e.g. GdkEventMask
== EventMask
is no longer a valid assumption). The Swift type can still be constructed from the underlying C type. To get the underlying C value from the Swift type, use the value
property.
Is there a way to set the event mask without using
rawValue
and casting?add(events) expects CInt (Int32) while GDK_KEY_PRESS_MASK is UInt32