-
Notifications
You must be signed in to change notification settings - Fork 711
compiler: Have a key-sequence
type
#8906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| Type::Image | ||
| Type::Easing | ||
| Type::Array(_) | ||
| Type::KeyboardShortcut => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tired to return a String that contains the stringified definition, but that causes infinite recursion... I need to check out why that happens in detail.
/// @keys(ctrl +shift + alt+meta+a) | ||
/// @keys(control +shift + alt+meta+a) | ||
/// ``` | ||
fn parse_keys(p: &mut impl Parser) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should allow ,
separated lists of elements.
The logic to decide on the actual key being uses is also a bit simplistic: We should (in addition?) accept the keys from our Keys
namespace. But So I should probably let all unknown identifiers through here and match them to the Keys namespace (or the single character).
... which is lowered to a string for now.
78e44e2
to
7b8e4d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry i haven't took the time to review this before my vacations.
I've had a quick look at it and didn't see anything wrong.
I'm thinking we shouldn't merge this to master (stabilize) unless this is used. Would it be easy to gate this as an experimental feature? (the new type and the @keys
)
@@ -839,6 +845,40 @@ impl Enumeration { | |||
} | |||
} | |||
|
|||
#[derive(Clone, Debug, Default)] | |||
pub struct KeyboardModifiers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we already have such a type somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do. But I can not get to it from here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have this type in i_slint_core
, but that is not listed in the compiler's Cargo.toml. I did not want to add it, as there is probably a reason for not having that.
let ctrl = if self.modifiers.control { "ctrl+" } else { "" }; | ||
let meta = if self.modifiers.meta { "meta+" } else { "" }; | ||
let shift = if self.modifiers.shift { "shift+" } else { "" }; | ||
write!(f, "{alt}{ctrl}{meta}{shift}{}", self.key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we also want to support key that are not printable like arrows, enter, media keys, F keys and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that will be needed.
I wanted to keep this unmerged for the time being and build on top of this PR. |
... which is lowered to a string for now.
Add a new type
keyboard-shortcut
, that is parsed from@keys(shift + control + a)
and gets lowered to a string in Rust and C++ and the interpreter for now.