Apologies if this is a dumb question, but I'm new to IntraWeb, and I'm sure it must have a simple answer.
I have a simple logon form, with a TTIWEmailEdit component, a TTIWAdvEdit component (essentially username and password), plus a TIWButton.
I have an OnClick event for the TIWButton, which logs into a database, verifies the username/password and shows the next form if successful, or an error dialog if not.
I would like to be able to press Enter on the username or password fields to activate the button's OnClick event, rather than directly clicking the button.
I've implemented an OnAsyncKeyPress event for the edit controls, as follows:
if EventParams.Values['which']='13' then //check for 'Enter'
begin
iwbLogonClick(iwbLogon);
end;
This does call the button's OnClick, but my next form is not displayed (nor any error message if the login failed)
I assume it's because it's now being called from an asynchronous event, whereas the button's OnClick is non-asynchronous. As there is no OnKeyPress event for the edit controls, how can I implement this behavior?
Thanks for helping an IntraWeb novice.
Hi,
Hi Bart,
Thanks, that worked. In fact, just putting the call to the button's OnClick in the OnSubmit
event seemed to work whether I had SubmitOnReturn set at either true or
false!! Also, the same worked in an ordinary TIWEdit (which doesn't have
a SubmitOnReturn property) Do you know if pressing Enter on any TIWEdit
descendants will cause OnSubmit to be called?
However, my real logon form is actually a bit more complex. There are 4 additional 'quick launch' buttons which cause one of four different screens to load after logon. I'd like to be able to launch these by pressing a function key (F1 to F4) on the username or password fields, using the same OnAsyncKeyPress code as described in my first post, which would call one of the 4 button's OnCLick event. However, the same thing happens, the OnClick code is called, but the next form is not displayed.
I think what I'm essentially asking is whether I can cause an Async event to behave like a Non Async event!!
- I would assume that this technique works for all TIWEdit descendant controls that have an OnSubmit event.- I'm not sure if this kind of functionality is supported in Async events.
As this is more of a general IntraWeb question, maybe you can try contacting Atozed Software or write a post in the IntraWeb forums (https://forums.embarcadero.com/forum.jspa?forumID=93) for further assistance?
OK, will do. Thanks for your assistance.