deps: update zenolith and zenolith-sdl2

This commit is contained in:
LordMZTE 2024-01-18 21:35:30 +01:00
parent 6bfb7c11c6
commit 176e37e65b
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
2 changed files with 20 additions and 10 deletions

View file

@ -6,12 +6,12 @@
// Make sure this is the same version as the one used by zenolith-sdl2.
// See: https://git.mzte.de/zenolith/zenolith-sdl2
.zenolith = .{
.url = "git+https://git.mzte.de/zenolith/zenolith.git#6292688915f91da3ace4f38caa1dc33c718c8fc0",
.hash = "1220b709a856fe648fd5be6351b319d3626b3e368062d301e666a969032121b5ecde",
.url = "git+https://git.mzte.de/zenolith/zenolith.git#ad388687cd205079aab75074a542eadc79490df7",
.hash = "12201677a81b6f8133bbe9c7d3b2afc07b61bf632a070d13d57f995827022f6a1f54",
},
.zenolith_sdl2 = .{
.url = "git+https://git.mzte.de/zenolith/zenolith-sdl2.git#46431dbe65d50c899c3b701e2a3218dbaf1b4c8d",
.hash = "1220e3161064d9eae555ae33e74e0d0bcd07daa9a70b9052dd4094451f4b27ac2e2a",
.url = "git+https://git.mzte.de/zenolith/zenolith-sdl2.git#7da2841ec78918c613f7f21684881cb10f11749e",
.hash = "1220279b9f7b98c04566f23b436aa7a8c9000cc2f0b70301b0c10c11e7116bd5d0fc",
},
},

View file

@ -56,7 +56,7 @@ const Root = struct {
try vbox.addChild(null, hbox);
try vbox.addChild(null, try zl.widget.Spacer.init(alloc, .{ .flex = 1 }));
try vbox.addChild(null, try zl.widget.Label.init(alloc, "Hint: also try the plus and minus keys or tab + space!"));
try vbox.addChild(null, try zl.widget.Label.init(alloc, "Hint: also try the plus and minus keys or tab + space and Q!"));
const self = Root{
.box = vbox,
@ -87,22 +87,32 @@ const Root = struct {
},
// This event is fired when a letter is typed.
*zl.treevent.CharType => {
*zl.treevent.KeyInput => {
// Dispatch the key event to children first...
try tv.dispatch(selfw);
// If no child handled it, and it's a press event..
if (!tv.handled) {
if (!tv.handled and tv.action == .press and tv.key != null) {
// ... update the counter accordingly
switch (tv.codepoint) {
'+' => {
switch (tv.key.?) {
.plus => {
// Don't forget to mark the key input as handled!
tv.handled = true;
self.counter +%= 1;
try self.updateLabel();
},
'-' => {
.minus => {
tv.handled = true;
self.counter -%= 1;
try self.updateLabel();
},
.q => {
tv.handled = true;
// Example of downcasting a statspatch type to a certain implementation.
// The quit function is not defined by Zenolith, but by Zenolith-SDL2 only!
try selfw.data.platform.?.downcast(zsdl2.Sdl2Platform).?.quit();
},
else => {},
}
}