Skip to content

Commit

Permalink
Disabled the text selection context menu in the KioskBrowser demo
Browse files Browse the repository at this point in the history
Fixed issue #7 : The focus is now removed from the focused control when the browser gets the focus.
Use TNetEncoding.URL in Delphi XE7 and newer versions
  • Loading branch information
salvadordf committed Feb 10, 2022
1 parent a27211c commit 82cccc0
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 9 deletions.
1 change: 1 addition & 0 deletions demos/Delphi_FMX/SimpleFMXBrowser/uMainForm.fmx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ object MainForm: TMainForm
AllowSingleSignOnUsingOSPrimaryAccount = False
OnInitializationError = WVFMXBrowser1InitializationError
OnAfterCreated = WVFMXBrowser1AfterCreated
OnGotFocus = WVFMXBrowser1GotFocus
Left = 104
Top = 104
end
Expand Down
14 changes: 14 additions & 0 deletions demos/Delphi_FMX/SimpleFMXBrowser/uMainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ TMainForm = class(TForm)

procedure WVFMXBrowser1AfterCreated(Sender: TObject);
procedure WVFMXBrowser1InitializationError(Sender: TObject; aErrorCode: HRESULT; const aErrorMessage: wvstring);
procedure WVFMXBrowser1GotFocus(Sender: TObject);

private
FMXWindowParent : TWVFMXWindowParent;
Expand Down Expand Up @@ -260,6 +261,19 @@ procedure TMainForm.WVFMXBrowser1AfterCreated(Sender: TObject);
AddressPnl.Enabled := True;
end;

procedure TMainForm.WVFMXBrowser1GotFocus(Sender: TObject);
var
TempObject : TFMXObject;
begin
if (Focused <> nil) then
begin
TempObject := Focused.GetObject;

if (TempObject <> nil) and (TempObject is TControl) then
TControl(TempObject).ResetFocus;
end;
end;

procedure TMainForm.WVFMXBrowser1InitializationError(Sender: TObject;
aErrorCode: HRESULT; const aErrorMessage: wvstring);
begin
Expand Down
7 changes: 4 additions & 3 deletions demos/Delphi_VCL/KioskBrowser/uKioskBrowser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ procedure TMainForm.WMMoving(var aMessage : TMessage);
end;

initialization
GlobalWebView2Loader := TWVLoader.Create(nil);
GlobalWebView2Loader.UserDataFolder := ExtractFileDir(Application.ExeName) + '\CustomCache';
GlobalWebView2Loader.KioskPrinting := True; // This property enables silent priting
GlobalWebView2Loader := TWVLoader.Create(nil);
GlobalWebView2Loader.UserDataFolder := ExtractFileDir(Application.ExeName) + '\CustomCache';
GlobalWebView2Loader.KioskPrinting := True; // This property enables silent priting
GlobalWebView2Loader.DisableFeatures := 'msWebOOUI,msPdfOOUI'; // Disable the text selection context menu
GlobalWebView2Loader.StartWebView2;

end.
3 changes: 2 additions & 1 deletion packages/WebView4DelphiVCLRTL.dpk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ package WebView4DelphiVCLRTL;

requires
rtl,
vcl;
vcl,
inet;

contains
uWVConstants in '..\source\uWVConstants.pas',
Expand Down
4 changes: 2 additions & 2 deletions source/uWVBrowserBase.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2942,7 +2942,7 @@ procedure TWVBrowserBase.doOnRetrieveHTMLCompleted(aErrorCode: HRESULT; const aR

if succeeded(aErrorCode) then
begin
{$IFDEF DELPHI26_UP}
{$IFDEF DELPHI21_UP}
TempHTML := TNetEncoding.URL.Decode(aResultObjectAsJson);
{$ELSE}
{$IFDEF FPC}
Expand Down Expand Up @@ -2979,7 +2979,7 @@ procedure TWVBrowserBase.doOnRetrieveTextCompleted(aErrorCode: HRESULT; const aR

if succeeded(aErrorCode) then
begin
{$IFDEF DELPHI26_UP}
{$IFDEF DELPHI21_UP}
TempText := TNetEncoding.URL.Decode(aResultObjectAsJson);
{$ELSE}
{$IFDEF FPC}
Expand Down
20 changes: 18 additions & 2 deletions source/uWVFMXWindowParent.pas
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ TWVFMXWindowParent = class(TCommonCustomForm)

procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Resize; override;
{$IFDEF DELPHI18_UP}
procedure DoFocusChanged; override;
{$ELSE}
procedure SetActive(const Value: Boolean); override;

{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
procedure Reparent(const aNewParentHandle : {$IFDEF DELPHI18_UP}TWindowHandle{$ELSE}TFmxHandle{$ENDIF});
Expand Down Expand Up @@ -55,7 +58,10 @@ constructor TWVFMXWindowParent.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

FBrowser := nil;
FBrowser := nil;
Caption := '';
BorderStyle := TFmxFormBorderStyle.{$IFDEF DELPHI20_UP}None{$ELSE}bsNone{$ENDIF};
BorderIcons := [];
end;

procedure TWVFMXWindowParent.Resize;
Expand All @@ -65,13 +71,23 @@ procedure TWVFMXWindowParent.Resize;
UpdateSize;
end;

{$IFDEF DELPHI18_UP}
procedure TWVFMXWindowParent.DoFocusChanged;
begin
inherited DoFocusChanged;

if (Focused <> nil) and (FBrowser <> nil) then
FBrowser.SetFocus;
end;
{$ELSE}
procedure TWVFMXWindowParent.SetActive(const Value: Boolean);
begin
inherited SetActive(Value);

if Value and (Focused <> nil) and (FBrowser <> nil) then
FBrowser.SetFocus;
end;
{$ENDIF}

function TWVFMXWindowParent.GetBrowser: TWVBrowserBase;
begin
Expand Down
2 changes: 2 additions & 0 deletions source/uWVLoader.pas
Original file line number Diff line number Diff line change
Expand Up @@ -811,12 +811,14 @@ function TWVLoader.GetCustomCommandLineSwitches : wvstring;
// The list of features you can enable is here :
// https://chromium.googlesource.com/chromium/src/+/master/chrome/common/chrome_features.cc
// https://source.chromium.org/chromium/chromium/src/+/main:content/public/common/content_features.cc
// https://source.chromium.org/search?q=base::Feature
if (length(FEnableFeatures) > 0) then
Result := Result + '--enable-features=' + FEnableFeatures + ' ';

// The list of features you can disable is here :
// https://chromium.googlesource.com/chromium/src/+/master/chrome/common/chrome_features.cc
// https://source.chromium.org/chromium/chromium/src/+/main:content/public/common/content_features.cc
// https://source.chromium.org/search?q=base::Feature
TempFeatures := FDisableFeatures;

if not(FSmartScreenProtectionEnabled) then
Expand Down
2 changes: 1 addition & 1 deletion update_CEF4Delphi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 31,
"InternalVersion" : 32,
"Name" : "webview4delphi.lpk",
"Version" : "1.0.1108.44"
}
Expand Down

0 comments on commit 82cccc0

Please sign in to comment.