C
C#3w ago
Noargh

Avalonia Issue

Im having an issue in my wordle clone with when i type with the onscreen keyboard then press the enter key it types the same character that you pressed. Its been giving me quite a bit of trouble. I have a relay command named Press() and it calls the typecharacter function. Im thinking that it is the problem but i cant see anything. https://github.com/NoahWeddles/Wordle-Clone
GitHub
GitHub - NoahWeddles/Wordle-Clone
Contribute to NoahWeddles/Wordle-Clone development by creating an account on GitHub.
23 Replies
Noargh
NoarghOP3w ago
ok ill assume thats it
Keswiik
Keswiik3w ago
at least, i think it needs focus to receive key down events either way, that's likely the culprit
Noargh
NoarghOP3w ago
ok how could i circumvent that
Keswiik
Keswiik3w ago
could always subclass Button and override both OnKeyDown and OnKeyUp to make it ignore all button presses so it only works with mouse clicks not sure if that would cause any issues, but it would be very easy to test
Noargh
NoarghOP3w ago
ok "subclassing" Button would entail creating a custom control for use in my xaml file right? or am i misunderstanding you
Keswiik
Keswiik3w ago
just make a class that inherits from Button and override those two methods and make them do nothing
Noargh
NoarghOP3w ago
a seperate file or within my MainWindowViewModel.cs
Keswiik
Keswiik3w ago
I personally do not put more than 1 class in a file
Noargh
NoarghOP3w ago
like this?
No description
Keswiik
Keswiik3w ago
$tias
Noargh
NoarghOP3w ago
alr ok
Noargh
NoarghOP3w ago
No description
Noargh
NoarghOP3w ago
i have this which from my logic should override the original function of the onkeydown event in the button class
Keswiik
Keswiik3w ago
ya
Noargh
NoarghOP3w ago
my issue is with using this class how can i replace my <Button> s function with this?
Keswiik
Keswiik3w ago
by changing <Button> to <FixedButton>
Noargh
NoarghOP3w ago
No description
Noargh
NoarghOP3w ago
its not working
Keswiik
Keswiik3w ago
probably need to make sure the correct namespace is imported i don't use VS with avalonia, but rider always handles the imports for me sec xmlns:controls1="clr-namespace:Aggregator.UI.Dataset.Manager.Rewrite.Controls" something like this (example from one of my avalonia projects) which can be used like <controls1:YourControlName>
Noargh
NoarghOP3w ago
alright i have it figured out tysm :Ok:
Keswiik
Keswiik3w ago
:PepoSalute:

Did you find this page helpful?