C
C#10mo ago
Stark✨

Metro Set Ui Key Events dont work

am trying to create a simple program using windows forms C# and have a text box and a list... i can add text to the list using another button but when i try to add text using the keypress event it just dings and nothing happens
33 Replies
SinFluxx
SinFluxx10mo ago
$details
MODiX
MODiX10mo ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
Stark✨
Stark✨OP10mo ago
BlazeBin - ciohcrupjgkk
A tool for sharing your source code with the world!
Stark✨
Stark✨OP10mo ago
my input is a keypress <Enter> in the text box and i expect it to fill the list with what ever content the text box has but this isnt happening and i just hear a ding sound once i press the key
SinFluxx
SinFluxx10mo ago
Have you tried debugging to see what's actually happening?
Stark✨
Stark✨OP10mo ago
there is no error whatsoever
SinFluxx
SinFluxx10mo ago
Right, but debug to see if it's actually hitting that event handler at all Set a breakpoint, run your app, press enter in the textbox
Stark✨
Stark✨OP10mo ago
nope it dosent hit the event handler
SinFluxx
SinFluxx10mo ago
Have you checked the properties of your textbox to see if the event handler for KeyDown is set correctly?
Stark✨
Stark✨OP10mo ago
yes key preview is true
SinFluxx
SinFluxx10mo ago
So you're handling it in a different event handler?
Stark✨
Stark✨OP10mo ago
no its in the same event handler or i dint get what u were tryna say
SinFluxx
SinFluxx10mo ago
well you'd set keypreview = true if you want the key press event to be handled by your Form rather than by the specific control https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.form.keypreview?view=windowsdesktop-8.0 So I assumed you mentioned that because you were handling the keydown event in some other event handler...
Stark✨
Stark✨OP10mo ago
yea i want it to be handled by the form but if u mean handling by the form is not same as being handled by the text box in the form i think its better off no no i want the key event handler just for the text box
SinFluxx
SinFluxx10mo ago
Right, so you don't need to set KeyPreview = true then?
Stark✨
Stark✨OP10mo ago
is that a question? T_T
SinFluxx
SinFluxx10mo ago
Sort of, unless you've got it set because of some other reason I don't think you need it set
Stark✨
Stark✨OP10mo ago
no no i just set it true for this purpose i dont need it for anything else
SinFluxx
SinFluxx10mo ago
Then you don't need it set
Stark✨
Stark✨OP10mo ago
ok i set it true cuz some forums said it helps
SinFluxx
SinFluxx10mo ago
If there's a reason to set it, like you want to handle key press events at a form level first, then go on to the specific control event handler then sure Are you still seeing the issue after removing that?
Stark✨
Stark✨OP10mo ago
it was already removed previously and i still had the issue.. turning it on dint have any effecct also am using a metro set ui can this be the reason?
SinFluxx
SinFluxx10mo ago
Shouldn't be In your textbox properties, is the KeyDown event handler properly set?
SinFluxx
SinFluxx10mo ago
No description
Stark✨
Stark✨OP10mo ago
yea it is set
SinFluxx
SinFluxx10mo ago
Saying that, someone did log this: https://github.com/N-a-r-w-i-n/MetroSet-UI/issues/44
GitHub
MetroTextBox not react to keys · Issue #44 · N-a-r-w-i-n/MetroSet-UI
Don't work with _keydown, for "Enter" keycode at leat.
SinFluxx
SinFluxx10mo ago
Maybe just try it with a normal winforms textbox and see if that works
Stark✨
Stark✨OP10mo ago
i could but i already built my program using metroset ui T_T
SinFluxx
SinFluxx10mo ago
For the sake of proving the point it will only take you a minute to try it
Stark✨
Stark✨OP10mo ago
ai8 lemme make one quick yea it workes in a normal form @SinFluxx
SinFluxx
SinFluxx10mo ago
I mean the easiest way might be to move it to the KeyUp event instead?
Stark✨
Stark✨OP10mo ago
i tried all three
SinFluxx
SinFluxx10mo ago
I mean that issue I linked above was logged 2021, and from a glance there haven't been any updates to the repo in 4 years, so it may just be an issue you're stuck with unless someone knows some way around it
Want results from more Discord servers?
Add your server