<div dir="ltr"><div>The apri function has Wait command inside it? That is not allowed, because wait calls the event loop. Use Sleep (or timer) instead.<br></div><div><br></div><div><br></div><div>Jussi<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 18, 2019 at 9:19 PM Marco Ancillotti <<a href="mailto:gambas@servinfo.it">gambas@servinfo.it</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I made a function and moved the code but I get the same error.<br>
now I have:<br>
<br>
Public Sub Button1_Click()<br>
   apri()<br>
End<br>
<br>
Public Sub Form_KeyPress()<br>
   If Key.Code = Key.F1 Then apri()<br>
End<br>
<br>
the apri sub call a module that open a form with a simple yes/no <br>
question, works perfectly when I click button1 , hangs when I hit F1.<br>
<br>
<br>
Il 18/01/19 20:03, T Lee Davidson ha scritto:<br>
> Form_KeyPress is an event handler. Button1_Click is also an event handler. An event handler should not be called from within<br>
> another event handler.<br>
><br>
> I suggest moving the code that is in Button1_Click to a separate routine that can be called from either of the two handlers.<br>
><br>
><br>
> ___<br>
> Lee<br>
><br>
><br>
> On 1/18/19 1:46 PM, Marco Ancillotti wrote:<br>
>> Hi ,<br>
>><br>
>> I have a keypress form code that run a Button_click when someone hit F1 , somethink like:<br>
>><br>
>> Public Sub Form_KeyPress()<br>
>>    If Key.Code = Key.F1 Then Try Button1_Click()<br>
>> End<br>
>><br>
>> When I hit button with mouse everythink works well but when i press F1 I get:<br>
>><br>
>> gb.qt5: warning: calling the event loop during a keyboard event handler is ignored<br>
>><br>
>> and program hangs , no way to close , only stop button on ide stop it.<br>
>><br>
>> Any idea?<br>
>><br>
>> thank's in advance,<br>
>><br>
>> Marco.<br>
>><br>
>><br>
>><br>
>> ----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
> ----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
<br>
<br>
<br>
----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
</blockquote></div>