nandi/cosmicnimpublic Fork 0
1b15fda
Commits
Clone
git clone https://git.rickub.com/nandi/cosmicnim.git
git clone ssh://git@rickub.com/nandi/cosmicnim.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Listen for keys the way libcosmic does

This iced fork has no keyboard::on_key_press; libcosmic itself uses
event::listen_with, which cosmic::iced re-exports.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
nandithebull committed 2026-09-20T11:51:30-07:00 Browse files
1b15fda parent: 46a59a5
modified cosmic_ffi/src/lib.rs +5 -2
@@ -459,8 +459,11 @@ impl cosmic::Application for App {
459459 }
460460
461461 fn subscription(&self) -> cosmic::iced::Subscription<Message> {
462- use cosmic::iced::keyboard;
463- keyboard::on_key_press(|key, _modifiers| {
462+ use cosmic::iced::{event, keyboard, Event};
463+ event::listen_with(|event, _status, _window| {
464+ let Event::Keyboard(keyboard::Event::KeyPressed { key, .. }) = event else {
465+ return None;
466+ };
464467 let name = match key {
465468 keyboard::Key::Character(c) => c.to_string(),
466469 // Debug gives the variant name, which is exactly the spelling
@@ -459,8 +459,11 @@ impl cosmic::Application for App {
459 }459 }
460 460
461 fn subscription(&self) -> cosmic::iced::Subscription<Message> {461 fn subscription(&self) -> cosmic::iced::Subscription<Message> {
462- use cosmic::iced::keyboard;462+ use cosmic::iced::{event, keyboard, Event};
463- keyboard::on_key_press(|key, _modifiers| {463+ event::listen_with(|event, _status, _window| {
464+ let Event::Keyboard(keyboard::Event::KeyPressed { key, .. }) = event else {
465+ return None;
466+ };
464 let name = match key {467 let name = match key {
465 keyboard::Key::Character(c) => c.to_string(),468 keyboard::Key::Character(c) => c.to_string(),
466 // Debug gives the variant name, which is exactly the spelling469 // Debug gives the variant name, which is exactly the spelling