Below is a script that displays an HTML dialog. I would like to trap onkey for both ESC and PRINTSCREEN. There are several functions like onkeydown, but haven't figured out how to capture which key they pressed to process if is one of the 2 above - any ideas?
Code:
lastuse=toseconds(time()) 'Create an XDialog dialog box to prompt for parameters. DIM ans as P dim ans.object as p dim ans.class as c ans.class = "dhtmledit.dhtmledit" dim ans.events as c ans.events = <<%code% function contextmenuaction as v (itemIndex as N) end function function displaychanged as v () end function function documentcomplete as v () end function function onblur as v () end function function onclick as v () end function function ondblclick as v () end function function onkeydown as v () msgbox("","" + a_user.key.value)'does nothing end function function onkeypress as v () end function function onkeyup as v () end function function onmousedown as v () end function function onmousemove as v () end function function onmouseout as v () end function function onmouseover as v () end function function onmouseup as v () end function function onreadystatechange as v () end function function showcontextmenu as v (xPos as N,yPos as N) end function %code% DIM SHARED varC_result as C DIM ans_html as c ans_html = <<%html% <html> <head> <meta name="generator" content="Alpha Five HTML Editor"> <title></title> <style> <!-- p { margin-top: 0; margin-bottom: 0 } --> </style> </head> <body> <p>Note: for Rena, Billy, and appropriate others: the "Search" button for the SaltLog is now live - it was previously disabled. In the near future I will add search for MachineLogs. Also, in the near future we will be adding "hotkeys" to forms/screens. They will all follow the following format:</p> <p> </p> <p><u>N</u>ew Record (Ctrl N)</p> <p><u>S</u>ave (Ctrl S)</p> <p><u>E</u>dit (Ctrl E)</p> <p><u>F</u>ind (Ctrl F) the buttons were previously named Search, but will be renamed to Find</p> <p> note that on screens where there were/are multiple search buttons, as in Training, this will always refer to the</p> <p> top button named Find, for the parent records, and will always be named Find. Secondary search buttons</p> <p> will remain named Search, to avoid confusion.</p> <p><u>P</u>rint or Re<u>p</u>orts (Ctrl P)</p> <p>C<u>l</u>ose (Ctrl L) <strong><em>saves changes</em></strong> and closes</p> <p><u>M</u>ain Menu (Ctrl M)</p> <p> </p> <p>They have currently been added to the Machine Logs only. When you notice the button changes on a form, they will have been added to that screen.</p> <p> </p> <p>Other HotKeys are ESC (located at the top left of your keyboard), and Print Scrn (located at the top right of your keyboard.)</p> <p> </p> <p><strong><u>ESC</u></strong>: with rare exception, when you press the <strong>ESC</strong> key, if you have made a change to a field on a form, the change will be cancelled. If you have made a change to a field in a browse, and you have <strong>not yet moved to a different row</strong>, the change will be cancelled. If no changes have been made, the screen will close. So, in the new format, <strong>Ctrl-S</strong> and <strong>ESC</strong> would save the current record and close the screen. But note also that <strong>Ctrl-L</strong> will do the same thing.</p> <p><strong><u>Print Scr</u></strong>: with rare exception, this will print the current screen.</p> <p> </p> </body> </html>%html% ok_button_label = "&OK" cancel_button_label = "&Cancel" varC_result = ui_dlg_box("Notes to Employees",<<%dlg% {startup=init} {region} | {activex=120,33ans?.t.}; {endregion}; {line=1,0}; {region} <Close> {endregion}; %dlg%,<<%code% if a_dlg_button = "init" then a_dlg_button = "" ans.object.browsemode = .t. ans.object.appearance = 0 ans.object.ScrollBars = .t. on error goto ans_error ans.object.documenthtml = ans_html on error goto 0 ans.object.Refresh() a_dlg_button = "" end if end ans_error: ui_msg_box("Error","Invalid URL or HTML content.",UI_STOP_SYMBOL) end %code%)
Comment