Skip to content

Commit 094fbc7

Browse files
authored
Merge pull request #118 from ioa747/Event-Object-Refactoring
Event object refactoring
2 parents 484e3cb + 294a9cb commit 094fbc7

14 files changed

Lines changed: 395 additions & 255 deletions

NetWebView2Lib.au3

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#Tidy_Parameters=/tcb=-1
88

9-
; NetWebView2Lib.au3 - Script Version: 2026.2.25.11 🚩
9+
; NetWebView2Lib.au3 - Script Version: 2026.3.17.22 🚩
1010

1111
#include <Array.au3>
1212
#include <GUIConstantsEx.au3>
@@ -1498,7 +1498,7 @@ EndFunc ;==>__NetWebView2_freezer
14981498

14991499
#EndRegion ; === NetWebView2Lib UDF === #INTERNAL_USE_ONLY#
15001500

1501-
#Region ; === NetWebView2Lib UDF === EVENT HANDLERS === Collection ===
1501+
#Region ; === NetWebView2Lib UDF === EVENT HANDLERS ***** Collection *****
15021502

15031503
#Region ; === NetWebView2Lib UDF === EVENT HANDLERS === Error Handlers ===
15041504
; #INTERNAL_USE_ONLY# ===========================================================================================================
@@ -1628,9 +1628,17 @@ Volatile Func __NetWebView2_Events__OnMessageReceived($oWebV2M, $hGUI, $sMsg)
16281628
__NetWebView2_LastMessage_KEEPER($oWebV2M, $NETWEBVIEW2_MESSAGE__URL_CHANGED)
16291629

16301630
Case "NAV_ERROR"
1631-
__NetWebView2_Log(@ScriptLineNumber, $s_Prefix & " COMMAND:" & $sCommand, 1)
1632-
__NetWebView2_LastMessage_KEEPER($oWebV2M, $NETWEBVIEW2_MESSAGE__NAV_ERROR)
1633-
$oWebV2M.Stop()
1631+
If $sData = "OperationCanceled" Then ; Check if the error is actually a user cancellation
1632+
__NetWebView2_Log(@ScriptLineNumber, $s_Prefix & " COMMAND:" & $sCommand & " - USER_ABORT Data:" & $sData, 1)
1633+
__NetWebView2_LastMessage_KEEPER($oWebV2M, $NETWEBVIEW2_MESSAGE__USER_ABORT)
1634+
Else
1635+
__NetWebView2_Log(@ScriptLineNumber, $s_Prefix & " COMMAND:" & $sCommand & " Data:" & $sData, 1)
1636+
__NetWebView2_LastMessage_KEEPER($oWebV2M, $NETWEBVIEW2_MESSAGE__NAV_ERROR)
1637+
$oWebV2M.Stop() ; We only stop if it is a real error.
1638+
EndIf
1639+
1640+
; 🚧 *******************************************
1641+
ConsoleWrite("> TEST NAV_ERR: " & $sMsg & @CRLF)
16341642
ConsoleWrite("> TEST NAV_ERR: __NetWebView2_LastMessage_KEEPER($oWebV2M)=" & __NetWebView2_LastMessage_KEEPER($oWebV2M) & " SLN=" & @ScriptLineNumber & @CRLF)
16351643

16361644
Case "NAV_COMPLETED"
@@ -1948,19 +1956,20 @@ EndFunc ;==>__NetWebView2_Events__OnTitleChanged
19481956
; #INTERNAL_USE_ONLY# ===========================================================================================================
19491957
; Name ..........: __NetWebView2_Events__OnNavigationStarting
19501958
; Description ...:
1951-
; Syntax ........: __NetWebView2_Events__OnNavigationStarting($oWebV2M, $hGUI, $sURL)
1959+
; Syntax ........: __NetWebView2_Events__OnNavigationStarting($oWebV2M, $hGUI, $oArgs)
19521960
; Parameters ....: $oWebV2M - an object.
19531961
; $hGUI - a handle value.
1954-
; $sURL - a string value.
1962+
; $oArgs - an object.
19551963
; Return values .: None
19561964
; Author ........: ioa747, mLipok
19571965
; Modified ......:
19581966
; Remarks .......:
19591967
; Related .......:
1960-
; Link ..........:
1968+
; Link ..........: https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.navigationstarting
19611969
; Example .......: No
19621970
; ===============================================================================================================================
1963-
Volatile Func __NetWebView2_Events__OnNavigationStarting($oWebV2M, $hGUI, $sURL)
1971+
Volatile Func __NetWebView2_Events__OnNavigationStarting($oWebV2M, $hGUI, $oArgs)
1972+
Local $sURL = $oArgs.Uri
19641973
Local Const $s_Prefix = "[EVENT: OnNavigationStarting]: GUI:" & $hGUI & " URL: " & $sURL
19651974
__NetWebView2_Log(@ScriptLineNumber, (StringLen($s_Prefix) > 150 ? StringLeft($s_Prefix, 150) & "..." : $s_Prefix), 1)
19661975
__NetWebView2_LastMessage_KEEPER($oWebV2M, $NETWEBVIEW2_MESSAGE__NAV_STARTING)
@@ -2051,7 +2060,7 @@ EndFunc ;==>__NetWebView2_Events__OnContextMenu
20512060
; Modified ......:
20522061
; Remarks .......:
20532062
; Related .......:
2054-
; Link ..........: https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.webresourceresponsereceived?view=webview2-dotnet-1.0.2849.39
2063+
; Link ..........: https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.webresourceresponsereceived
20552064
; Example .......: No
20562065
; ===============================================================================================================================
20572066
Volatile Func __NetWebView2_Events__OnWebResourceResponseReceived($oWebV2M, $hGUI, $iStatusCode, $sReasonPhrase, $sRequestUrl)
@@ -2204,7 +2213,7 @@ EndFunc ;==>__NetWebView2_Events__OnProcessFailed
22042213
; Remarks .......: The host can provide a response with credentials for the authentication or cancel the request.
22052214
; If the host sets the Cancel property to false but does not provide either UserName or Password properties on the Response property, then WebView2 will show the default authentication challenge dialog prompt to the user.
22062215
; Related .......:
2207-
; Link ..........: https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.basicauthenticationrequested?view=webview2-dotnet-1.0.2903.40
2216+
; Link ..........: https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.basicauthenticationrequested
22082217
; Example .......: No
22092218
; ===============================================================================================================================
22102219
Volatile Func __NetWebView2_Events__OnBasicAuthenticationRequested($oWebV2M, $hGUI, $oArgs)
@@ -2303,11 +2312,11 @@ EndFunc ;==>__NetWebView2_Events__OnFrameNameChanged
23032312
; #INTERNAL_USE_ONLY# ===========================================================================================================
23042313
; Name ..........: __NetWebView2_Events__OnFrameNavigationStarting
23052314
; Description ...: Handles Frame NavigationStarting event
2306-
; Syntax ........: __NetWebView2_Events__OnFrameNavigationStarting($oWebV2M, $hGUI, $oFrame, $sUri)
2315+
; Syntax ........: __NetWebView2_Events__OnFrameNavigationStarting($oWebV2M, $hGUI, $oFrame, $oArgs)
23072316
; Parameters ....: $oWebV2M - an object.
23082317
; $hGUI - a handle value.
23092318
; $oFrame - an Frame object.
2310-
; $sUri - a string value.
2319+
; $oArgs - an object.
23112320
; Return values .: None
23122321
; Author ........: ioa747
23132322
; Modified ......:
@@ -2316,7 +2325,8 @@ EndFunc ;==>__NetWebView2_Events__OnFrameNameChanged
23162325
; Link ..........: https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2frame.navigationstarting
23172326
; Example .......: No
23182327
; ===============================================================================================================================
2319-
Volatile Func __NetWebView2_Events__OnFrameNavigationStarting($oWebV2M, $hGUI, $oFrame, $sUri)
2328+
Volatile Func __NetWebView2_Events__OnFrameNavigationStarting($oWebV2M, $hGUI, $oFrame, $oArgs)
2329+
Local $sUri = $oArgs.Uri
23202330
Local Const $s_Prefix = "[EVENT: OnFrameNavigationStarting]: WebV2M: " & VarGetType($oWebV2M) & " GUI:" & $hGUI & " Frame:" & VarGetType($oFrame) & " Uri:" & $sUri
23212331
__NetWebView2_Log(@ScriptLineNumber, $s_Prefix, 1)
23222332
; __NetWebView2_LastMessage_KEEPER($oWebV2M, $NETWEBVIEW2_MESSAGE__FRAME_NAV_STARTING) ; Optional: Update status if needed
@@ -2429,4 +2439,4 @@ EndFunc ;==>__NetWebView2_Events__FrameKeeper
24292439
;~ EndFunc ;==>__NetWebView2_Events__OnScreenCaptureStarting
24302440
#EndRegion ; === NetWebView2Lib UDF === EVENT HANDLERS * #TODO ===
24312441

2432-
#EndRegion ; === NetWebView2Lib UDF === EVENT HANDLERS === Collection ===
2442+
#EndRegion ; === NetWebView2Lib UDF === EVENT HANDLERS ***** Collection *****

0 commit comments

Comments
 (0)