feat(scrollable): make Container scrollable through Element Scrollable
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m35s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m35s
This commit is contained in:
@@ -60,17 +60,34 @@ pub const Key = packed struct {
|
||||
/// ```zig
|
||||
/// switch (event) {
|
||||
/// .quit => break,
|
||||
/// .key => |key| {
|
||||
/// // ctrl+c to quit
|
||||
/// if (key.eql(.{ .cp = 'c', .mod = .{ .ctrl = true } }))
|
||||
/// app.quit.set();
|
||||
/// },
|
||||
/// .key => |key| if (key.eql(.{ .cp = 'c', .mod = .{ .ctrl = true } })) app.quit.set(),
|
||||
/// else => {},
|
||||
/// }
|
||||
/// ```
|
||||
pub fn eql(this: @This(), other: @This()) bool {
|
||||
return std.meta.eql(this, other);
|
||||
}
|
||||
|
||||
/// Determine if the `Key` is an ascii character that can be printed to
|
||||
/// the screen. This means that the code point of the `Key` is an ascii
|
||||
/// character between 32 - 255 (with the exception of 127 = Delete) and no
|
||||
/// modifiers (alt and/or ctrl) are used.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// Get user input's from the .key event from the application event loop:
|
||||
///
|
||||
/// ```zig
|
||||
/// switch (event) {
|
||||
/// .key => |key| if (key.isAscii()) try this.input.append(key.cp),
|
||||
/// else => {},
|
||||
/// }
|
||||
/// ```
|
||||
pub fn isAscii(this: @This()) bool {
|
||||
return this.mod.alt == false and this.mod.ctrl == false and // no modifier keys
|
||||
(this.cp >= 32 and this.cp <= 126 or // ascii printable characters (except for input.Delete)
|
||||
this.cp >= 128 and this.cp <= 255); // extended ascii codes
|
||||
}
|
||||
};
|
||||
|
||||
// codepoints for keys
|
||||
|
||||
Reference in New Issue
Block a user