Frederick Posted October 9, 2019 Share Posted October 9, 2019 In my form's OnKeyDown event, I check for the pressing of the ESCAPE key to close the form. Before button(s) of the TUniPdfFrame component are clicked, pressing the ESCAPE key will be trapped. However, after button(s) of the TUniPdfFrame are clicked, the OnKeyDown event is no longer handled. Why does this happen? -- Frederick (UniGUI Complete - Professional Edition 1.90.0.1510) Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted October 10, 2019 Administrators Share Posted October 10, 2019 It happens because when you press a button inside PDF Frame the focus will be transferred to the iframe holding the PDF document. Quote Link to comment Share on other sites More sharing options...
Frederick Posted October 10, 2019 Author Share Posted October 10, 2019 4 hours ago, Farshad Mohajeri said: It happens because when you press a button inside PDF Frame the focus will be transferred to the iframe holding the PDF document. Is there a way to trap the ESCAPE key press from within the iframe and then close the form? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 11, 2019 Share Posted October 11, 2019 5 hours ago, Frederick said: Is there a way to trap the ESCAPE key press from within the iframe and then close the form? One of the possible solutions, it can be done by relaying keydown events to server manualy. Quote Link to comment Share on other sites More sharing options...
Frederick Posted October 11, 2019 Author Share Posted October 11, 2019 8 minutes ago, Sherzod said: One of the possible solutions, it can be done by relaying keydown events to server manualy. What code should I create and from which event? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 11, 2019 Share Posted October 11, 2019 6 minutes ago, Frederick said: What code should I create and from which event? Try this as an approximate solution. pdfFrame.OnFrameLoaded event: procedure TMainForm.pdfFrameFrameLoaded(Sender: TObject); begin pdfFrame.JSInterface.JSCode(#1'.iframe.contentDocument.addEventListener("keydown", function(e){ajaxRequest('+ Self.WebForm.JSForm.JSName +', "keydown", ["key="+e.keyCode])});') end; 1 Quote Link to comment Share on other sites More sharing options...
Frederick Posted October 11, 2019 Author Share Posted October 11, 2019 Thank you! This works perfectly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.