-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix tooltip behaviour * Fix formatting issues * Fix tooltip shown while dragging * Fix rounded corner rendering (#410) still won't work if border_radius < border_width / 2, since the radius is limited by the stroke width * Simplify boolean expression * Remove tooltip on pointer wheel * Replace add/remove tooltip functions to the possibility to listen keyboard without the view being focused * Add keyboard listenable example * Add keyboard listenable documentation * Revert tooltip field --------- Co-authored-by: Long0x0 <[email protected]> Co-authored-by: Ferran Alcaina <[email protected]>
- Loading branch information
1 parent
d87a6a1
commit b1b6bf4
Showing
8 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "keyboard_listener" | ||
edition = "2021" | ||
license.workspace = true | ||
version.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
floem = { path = "../.." } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use floem::event::{Event, EventListener}; | ||
use floem::reactive::create_rw_signal; | ||
use floem::views::label; | ||
use floem::{ | ||
view::View, | ||
views::{v_stack, Decorators}, | ||
widgets::text_input, | ||
EventPropagation, | ||
}; | ||
|
||
fn app_view() -> impl View { | ||
let text = create_rw_signal("".to_string()); | ||
let keyboard_signal = create_rw_signal("".to_string()); | ||
v_stack(( | ||
text_input(text) | ||
.placeholder("Write here") | ||
.keyboard_navigatable(), | ||
label(move || format!("Key Pressed: {}", keyboard_signal.get())) | ||
.keyboard_listenable() | ||
.on_event(EventListener::KeyDown, move |e| { | ||
if let Event::KeyDown(e) = e { | ||
keyboard_signal.set(e.key.logical_key.to_text().unwrap().to_string()); | ||
} | ||
EventPropagation::Continue | ||
}), | ||
)) | ||
} | ||
|
||
fn main() { | ||
floem::launch(app_view); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters