[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Convenient way to parse Enter on a textbox?
[Thread Prev] | [Thread Next]
- Subject: Re: Convenient way to parse Enter on a textbox?
- From: Gianluigi <gradobag@xxxxxxxxxxx>
- Date: Mon, 22 Sep 2025 15:51:51 +0200
- To: user@xxxxxxxxxxxxxxxxxxxxxx
Il 22/09/25 14:58, Admin ha scritto:
Greetings good people of Gambas!This should be pretty common thing in visual programming to create a program that allows user to type something in a field and hit enter to make it work, send it, right? Like, in Chat clients or something.So it should be pretty easy to trace Enter key while some textbox is in focus and react to it, is it not?I have a program that has a textbox and a "send" button. But.It seems to me that even having a sub like <anything>_KeyPress() brings a lot of "entropy" in to my program. This routine seems to be an event handler which "destroys" any "wait"s in the program, does not allow an interface to redraw itself before moving on to some long task, and finally, it does not even work right away.For example, in my Send button Sub I call another form to appear and then do "wait 0.1" for the form to actually appear, then I do other stuff. And it works. But if I call Button_Click sub from a KeyPress event of the textbox, it is ignored, debug window shows a warning that there is no use to call wait while keypress is active and the new form is not shown until all the routine of button_click is over.The workaround I use now is to just button.setfocus on Enter keypress and then I expect user to press enter again. So it's basically two enters instead of one to send a string from a textbox. It works, but I feel stupid.I strongly believe that it should be done much, much easier since it is a common task, and that I just don't understand Gambas enough.Can you please teach me the right way? Dmitry.
Hi, I probably didn't get the point, but this code works here: Public Sub TextBox1_KeyPress() If Key.Code = Key.Return Or If Key.Code = Key.Enter Then Button1_Click() Endif End Public Sub Button1_Click() Form1.Show End Long live free and democratic Ukraine Gianluigi
Re: Convenient way to parse Enter on a textbox? | Admin <admin@xxxxxxxxxx> |
Convenient way to parse Enter on a textbox? | Admin <admin@xxxxxxxxxx> |