mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-15 15:55:56 +01:00
Added workaround for focus issues in Linux
Added workaround for the CEF issue #2026 : https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on
This commit is contained in:
parent
e3f1a0902d
commit
6eddf7b5da
@ -3,7 +3,7 @@
|
||||
<ProjectSession>
|
||||
<Version Value="11"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="57">
|
||||
<Units Count="58">
|
||||
<Unit0>
|
||||
<Filename Value="ExternalPumpBrowser.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -19,12 +19,12 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="44"/>
|
||||
<CursorPos X="3" Y="171"/>
|
||||
<TopLine Value="235"/>
|
||||
<CursorPos X="6" Y="271"/>
|
||||
<UsageCount Value="49"/>
|
||||
<Bookmarks Count="2">
|
||||
<Item0 Y="258" ID="3"/>
|
||||
<Item1 X="57" Y="221" ID="1"/>
|
||||
<Item0 Y="273" ID="3"/>
|
||||
<Item1 X="57" Y="222" ID="1"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -424,8 +424,16 @@
|
||||
<CursorPos X="59" Y="135"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit56>
|
||||
<Unit57>
|
||||
<Filename Value="../SimpleBrowser2/usimplebrowser2.pas"/>
|
||||
<UnitName Value="uSimpleBrowser2"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="227"/>
|
||||
<CursorPos Y="234"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit57>
|
||||
</Units>
|
||||
<JumpHistory Count="10" HistoryIndex="9">
|
||||
<JumpHistory Count="13" HistoryIndex="12">
|
||||
<Position1>
|
||||
<Filename Value="uExternalPumpBrowser.pas"/>
|
||||
<Caret Line="153" Column="60" TopLine="127"/>
|
||||
@ -466,6 +474,18 @@
|
||||
<Filename Value="uExternalPumpBrowser.pas"/>
|
||||
<Caret Line="147" Column="16" TopLine="111"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="uExternalPumpBrowser.pas"/>
|
||||
<Caret Line="172" Column="3" TopLine="128"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="uExternalPumpBrowser.pas"/>
|
||||
<Caret Line="197" Column="82" TopLine="190"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="uExternalPumpBrowser.pas"/>
|
||||
<Caret Line="62" Column="15" TopLine="45"/>
|
||||
</Position13>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
|
@ -55,6 +55,7 @@ object Form1: TForm1
|
||||
Chromium = Chromium1
|
||||
end
|
||||
object Chromium1: TChromium
|
||||
OnGotFocus = Chromium1GotFocus
|
||||
OnBeforePopup = Chromium1BeforePopup
|
||||
OnAfterCreated = Chromium1AfterCreated
|
||||
OnBeforeClose = Chromium1BeforeClose
|
||||
|
@ -65,6 +65,7 @@ type
|
||||
procedure Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction: TCefCloseBrowserAction);
|
||||
procedure Chromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean);
|
||||
procedure Chromium1GotFocus(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean);
|
||||
|
||||
procedure FormCreate(Sender: TObject);
|
||||
@ -196,7 +197,7 @@ procedure TForm1.Chromium1BeforePopup(Sender: TObject;
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.Chromium1OpenUrlFromTab(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring;
|
||||
@ -245,14 +246,28 @@ begin
|
||||
AddressPnl.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TForm1.CEFLinkedWindowParent1Enter(Sender: TObject);
|
||||
begin
|
||||
If not(csDesigning in ComponentState) then Chromium1.SetFocus(True);
|
||||
end;
|
||||
|
||||
// This is a workaround for the CEF issue #2026
|
||||
// https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on
|
||||
// We use CEFLinkedWindowParent1.OnEnter, CEFLinkedWindowParent1.OnExit and
|
||||
// TChromium.OnGotFocus to avoid most of the focus issues.
|
||||
// CEFLinkedWindowParent1.TabStop must be TRUE.
|
||||
procedure TForm1.CEFLinkedWindowParent1Exit(Sender: TObject);
|
||||
begin
|
||||
if not(csDesigning in ComponentState) then Chromium1.SendCaptureLostEvent;
|
||||
if not(csDesigning in ComponentState) then
|
||||
Chromium1.SendCaptureLostEvent;
|
||||
end;
|
||||
|
||||
procedure TForm1.CEFLinkedWindowParent1Enter(Sender: TObject);
|
||||
begin
|
||||
if not(csDesigning in ComponentState) and
|
||||
Chromium1.Initialized and
|
||||
not(Chromium1.FrameIsFocused) then
|
||||
Chromium1.SendFocusEvent(True);
|
||||
end;
|
||||
|
||||
procedure TForm1.Chromium1GotFocus(Sender: TObject; const browser: ICefBrowser);
|
||||
begin
|
||||
CEFLinkedWindowParent1.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TForm1.WMMove(var Message: TLMMove);
|
||||
|
@ -3,14 +3,14 @@
|
||||
<ProjectSession>
|
||||
<Version Value="11"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="58">
|
||||
<Units Count="62">
|
||||
<Unit0>
|
||||
<Filename Value="SimpleBrowser2.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="18"/>
|
||||
<CursorPos X="74" Y="42"/>
|
||||
<UsageCount Value="45"/>
|
||||
<UsageCount Value="49"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
@ -20,11 +20,12 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="uSimpleBrowser2"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="113"/>
|
||||
<CursorPos X="54" Y="135"/>
|
||||
<UsageCount Value="45"/>
|
||||
<Bookmarks Count="1">
|
||||
<Item0 Y="249" ID="3"/>
|
||||
<TopLine Value="225"/>
|
||||
<CursorPos X="57" Y="246"/>
|
||||
<UsageCount Value="49"/>
|
||||
<Bookmarks Count="2">
|
||||
<Item0 X="57" Y="243" ID="3"/>
|
||||
<Item1 Y="239" ID="9"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -34,7 +35,7 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="Interfaces"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<UsageCount Value="43"/>
|
||||
<UsageCount Value="47"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="../../../../source/uCEFConstants.pas"/>
|
||||
@ -142,12 +143,11 @@
|
||||
<Unit18>
|
||||
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="43"/>
|
||||
<CursorPos X="59" Y="2566"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Bookmarks Count="2">
|
||||
<Item0 Y="2564" ID="1"/>
|
||||
<Item1 Y="4727" ID="2"/>
|
||||
<TopLine Value="6390"/>
|
||||
<CursorPos X="25" Y="6396"/>
|
||||
<UsageCount Value="23"/>
|
||||
<Bookmarks Count="1">
|
||||
<Item0 Y="4727" ID="2"/>
|
||||
</Bookmarks>
|
||||
</Unit18>
|
||||
<Unit19>
|
||||
@ -168,9 +168,9 @@
|
||||
<Filename Value="/usr/share/lazarus/2.0.10/lcl/controls.pp"/>
|
||||
<UnitName Value="Controls"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="1958"/>
|
||||
<CursorPos X="3" Y="1981"/>
|
||||
<UsageCount Value="14"/>
|
||||
<TopLine Value="2223"/>
|
||||
<CursorPos X="14" Y="2244"/>
|
||||
<UsageCount Value="15"/>
|
||||
</Unit21>
|
||||
<Unit22>
|
||||
<Filename Value="/usr/share/lazarus/2.0.10/lcl/lcltype.pp"/>
|
||||
@ -203,8 +203,7 @@
|
||||
<Unit26>
|
||||
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk+/gtk/gtkwidget.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="69"/>
|
||||
<CursorPos X="4" Y="96"/>
|
||||
<CursorPos X="4" Y="5"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit26>
|
||||
<Unit27>
|
||||
@ -235,9 +234,9 @@
|
||||
<Unit31>
|
||||
<Filename Value="../../../source/uCEFLinkedWindowParent.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="51"/>
|
||||
<CursorPos X="17" Y="73"/>
|
||||
<UsageCount Value="18"/>
|
||||
<TopLine Value="48"/>
|
||||
<CursorPos X="69" Y="75"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit31>
|
||||
<Unit32>
|
||||
<Filename Value="../../../../fpCEF3/cef3lib.pas"/>
|
||||
@ -249,9 +248,9 @@
|
||||
<Unit33>
|
||||
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/x11/src/xlib.pp"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="1445"/>
|
||||
<CursorPos X="10" Y="1467"/>
|
||||
<UsageCount Value="10"/>
|
||||
<TopLine Value="1285"/>
|
||||
<CursorPos X="10" Y="1307"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit33>
|
||||
<Unit34>
|
||||
<Filename Value="../../../source/uCEFLibFunctions.pas"/>
|
||||
@ -277,8 +276,8 @@
|
||||
<Unit37>
|
||||
<Filename Value="../../../source/uCEFInterfaces.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="2269"/>
|
||||
<CursorPos X="3" Y="2276"/>
|
||||
<TopLine Value="606"/>
|
||||
<CursorPos X="15" Y="626"/>
|
||||
<UsageCount Value="16"/>
|
||||
</Unit37>
|
||||
<Unit38>
|
||||
@ -332,9 +331,12 @@
|
||||
<Unit44>
|
||||
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/opengles/examples/es2example1.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="156"/>
|
||||
<CursorPos X="75" Y="192"/>
|
||||
<UsageCount Value="10"/>
|
||||
<TopLine Value="170"/>
|
||||
<CursorPos X="16" Y="228"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Bookmarks Count="1">
|
||||
<Item0 X="47" Y="194" ID="1"/>
|
||||
</Bookmarks>
|
||||
</Unit44>
|
||||
<Unit45>
|
||||
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/x11/src/x.pp"/>
|
||||
@ -414,7 +416,8 @@
|
||||
<Unit55>
|
||||
<Filename Value="../../../source/uCEFClient.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="61"/>
|
||||
<TopLine Value="622"/>
|
||||
<CursorPos X="21" Y="645"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit55>
|
||||
<Unit56>
|
||||
@ -425,91 +428,87 @@
|
||||
<Unit57>
|
||||
<Filename Value="../../../source/uCEFBrowserProcessHandler.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="220"/>
|
||||
<CursorPos Y="252"/>
|
||||
<TopLine Value="289"/>
|
||||
<CursorPos X="92" Y="323"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit57>
|
||||
<Unit58>
|
||||
<Filename Value="../../../source/uCEFPrintHandler.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="97"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit58>
|
||||
<Unit59>
|
||||
<Filename Value="../../../source/uCEFBrowser.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="487"/>
|
||||
<CursorPos Y="511"/>
|
||||
<UsageCount Value="12"/>
|
||||
</Unit59>
|
||||
<Unit60>
|
||||
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/examples/gettingstarted/gettingstarted.pas"/>
|
||||
<UnitName Value="GettingStarted"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<CursorPos X="7" Y="6"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit60>
|
||||
<Unit61>
|
||||
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk2x11/include/gdkx.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="220"/>
|
||||
<CursorPos X="54" Y="232"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit61>
|
||||
</Units>
|
||||
<JumpHistory Count="16" HistoryIndex="15">
|
||||
<JumpHistory Count="11" HistoryIndex="10">
|
||||
<Position1>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="214" Column="47" TopLine="187"/>
|
||||
<Caret Line="245" Column="35" TopLine="242"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="268" Column="61" TopLine="231"/>
|
||||
<Caret Line="257" Column="66" TopLine="231"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="91" TopLine="70"/>
|
||||
<Caret Line="75" Column="15" TopLine="68"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="211" TopLine="187"/>
|
||||
<Caret Line="286" Column="59" TopLine="251"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="265" Column="85" TopLine="229"/>
|
||||
<Caret Line="264" TopLine="252"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="266" TopLine="229"/>
|
||||
<Caret Line="76" Column="37" TopLine="39"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="219" Column="5" TopLine="193"/>
|
||||
<Caret Line="275" TopLine="251"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="119" Column="67" TopLine="36"/>
|
||||
<Caret Line="250" Column="66" TopLine="236"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="85" Column="35" TopLine="70"/>
|
||||
<Caret Line="89" TopLine="68"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="63" Column="27" TopLine="53"/>
|
||||
<Caret Line="239" TopLine="234"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="216" Column="5" TopLine="197"/>
|
||||
<Caret Line="76" Column="38" TopLine="51"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="137" Column="43" TopLine="101"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="139" TopLine="101"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="135" TopLine="125"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="140" TopLine="125"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="usimplebrowser2.pas"/>
|
||||
<Caret Line="145" TopLine="125"/>
|
||||
</Position16>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="0" ActiveMode=""/>
|
||||
</RunParams>
|
||||
</ProjectSession>
|
||||
<Debugging>
|
||||
<BreakPoints Count="1">
|
||||
<Item1>
|
||||
<Kind Value="bpkSource"/>
|
||||
<WatchScope Value="wpsLocal"/>
|
||||
<WatchKind Value="wpkWrite"/>
|
||||
<Source Value="../../../../source/uCEFChromiumCore.pas"/>
|
||||
<Line Value="4373"/>
|
||||
</Item1>
|
||||
</BreakPoints>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
@ -30,6 +30,7 @@ object Form1: TForm1
|
||||
Align = alRight
|
||||
Caption = 'Go'
|
||||
OnClick = GoBtnClick
|
||||
OnEnter = CEFLinkedWindowParent1Exit
|
||||
TabOrder = 0
|
||||
end
|
||||
object AddressEdt: TEdit
|
||||
@ -38,6 +39,7 @@ object Form1: TForm1
|
||||
Top = 0
|
||||
Width = 932
|
||||
Align = alClient
|
||||
OnEnter = CEFLinkedWindowParent1Exit
|
||||
TabOrder = 1
|
||||
Text = 'https://www.google.com'
|
||||
end
|
||||
@ -55,6 +57,7 @@ object Form1: TForm1
|
||||
Chromium = Chromium1
|
||||
end
|
||||
object Chromium1: TChromium
|
||||
OnGotFocus = Chromium1GotFocus
|
||||
OnBeforePopup = Chromium1BeforePopup
|
||||
OnAfterCreated = Chromium1AfterCreated
|
||||
OnBeforeClose = Chromium1BeforeClose
|
||||
|
@ -58,13 +58,11 @@ type
|
||||
AddressPnl: TPanel;
|
||||
Timer1: TTimer;
|
||||
|
||||
procedure CEFLinkedWindowParent1Enter(Sender: TObject);
|
||||
procedure CEFLinkedWindowParent1Exit(Sender: TObject);
|
||||
|
||||
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction: TCefCloseBrowserAction);
|
||||
procedure Chromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean);
|
||||
procedure Chromium1GotFocus(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean);
|
||||
|
||||
procedure FormCreate(Sender: TObject);
|
||||
@ -72,7 +70,10 @@ type
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
|
||||
procedure GoBtnClick(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
|
||||
procedure CEFLinkedWindowParent1Enter(Sender: TObject);
|
||||
procedure CEFLinkedWindowParent1Exit(Sender: TObject);
|
||||
private
|
||||
|
||||
protected
|
||||
@ -182,7 +183,7 @@ procedure TForm1.Chromium1BeforePopup(Sender: TObject;
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.Chromium1OpenUrlFromTab(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring;
|
||||
@ -230,14 +231,28 @@ begin
|
||||
SendCompMessage(CEF_AFTERCREATED);
|
||||
end;
|
||||
|
||||
procedure TForm1.CEFLinkedWindowParent1Enter(Sender: TObject);
|
||||
begin
|
||||
If not(csDesigning in ComponentState) then Chromium1.SetFocus(True);
|
||||
end;
|
||||
|
||||
// This is a workaround for the CEF issue #2026
|
||||
// https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on
|
||||
// We use CEFLinkedWindowParent1.OnEnter, CEFLinkedWindowParent1.OnExit and
|
||||
// TChromium.OnGotFocus to avoid most of the focus issues.
|
||||
// CEFLinkedWindowParent1.TabStop must be TRUE.
|
||||
procedure TForm1.CEFLinkedWindowParent1Exit(Sender: TObject);
|
||||
begin
|
||||
if not(csDesigning in ComponentState) then Chromium1.SendCaptureLostEvent;
|
||||
if not(csDesigning in ComponentState) then
|
||||
Chromium1.SendCaptureLostEvent;
|
||||
end;
|
||||
|
||||
procedure TForm1.CEFLinkedWindowParent1Enter(Sender: TObject);
|
||||
begin
|
||||
if not(csDesigning in ComponentState) and
|
||||
Chromium1.Initialized and
|
||||
not(Chromium1.FrameIsFocused) then
|
||||
Chromium1.SendFocusEvent(True);
|
||||
end;
|
||||
|
||||
procedure TForm1.Chromium1GotFocus(Sender: TObject; const browser: ICefBrowser);
|
||||
begin
|
||||
CEFLinkedWindowParent1.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TForm1.BrowserCreatedMsg(Data: PtrInt);
|
||||
|
@ -3,7 +3,7 @@
|
||||
<ProjectSession>
|
||||
<Version Value="11"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="58">
|
||||
<Units Count="59">
|
||||
<Unit0>
|
||||
<Filename Value="SubProcess.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -20,11 +20,11 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="95"/>
|
||||
<CursorPos X="31" Y="109"/>
|
||||
<TopLine Value="50"/>
|
||||
<CursorPos Y="61"/>
|
||||
<UsageCount Value="46"/>
|
||||
<Bookmarks Count="1">
|
||||
<Item0 Y="235" ID="3"/>
|
||||
<Item0 Y="250" ID="3"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -436,8 +436,16 @@
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit57>
|
||||
<Unit58>
|
||||
<Filename Value="../SimpleBrowser2/usimplebrowser2.pas"/>
|
||||
<UnitName Value="uSimpleBrowser2"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="53"/>
|
||||
<CursorPos X="60" Y="73"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit58>
|
||||
</Units>
|
||||
<JumpHistory Count="25" HistoryIndex="24">
|
||||
<JumpHistory Count="28" HistoryIndex="27">
|
||||
<Position1>
|
||||
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
|
||||
<Caret Line="1613" TopLine="1591"/>
|
||||
@ -538,6 +546,18 @@
|
||||
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
|
||||
<Caret Line="2950" TopLine="2928"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="uSubProcess.pas"/>
|
||||
<Caret Line="110" Column="31" TopLine="96"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="uSubProcess.pas"/>
|
||||
<Caret Line="171" Column="6" TopLine="162"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="uSubProcess.pas"/>
|
||||
<Caret Line="62" Column="15" TopLine="45"/>
|
||||
</Position28>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
|
@ -55,6 +55,7 @@ object Form1: TForm1
|
||||
Chromium = Chromium1
|
||||
end
|
||||
object Chromium1: TChromium
|
||||
OnGotFocus = Chromium1GotFocus
|
||||
OnBeforePopup = Chromium1BeforePopup
|
||||
OnAfterCreated = Chromium1AfterCreated
|
||||
OnBeforeClose = Chromium1BeforeClose
|
||||
|
@ -58,13 +58,11 @@ type
|
||||
AddressPnl: TPanel;
|
||||
Timer1: TTimer;
|
||||
|
||||
procedure CEFLinkedWindowParent1Enter(Sender: TObject);
|
||||
procedure CEFLinkedWindowParent1Exit(Sender: TObject);
|
||||
|
||||
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction: TCefCloseBrowserAction);
|
||||
procedure Chromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean);
|
||||
procedure Chromium1GotFocus(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean);
|
||||
|
||||
procedure FormCreate(Sender: TObject);
|
||||
@ -72,7 +70,10 @@ type
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
|
||||
procedure GoBtnClick(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
|
||||
procedure CEFLinkedWindowParent1Enter(Sender: TObject);
|
||||
procedure CEFLinkedWindowParent1Exit(Sender: TObject);
|
||||
private
|
||||
|
||||
protected
|
||||
@ -168,7 +169,7 @@ procedure TForm1.Chromium1BeforePopup(Sender: TObject;
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.Chromium1OpenUrlFromTab(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring;
|
||||
@ -216,14 +217,28 @@ begin
|
||||
SendCompMessage(CEF_AFTERCREATED);
|
||||
end;
|
||||
|
||||
procedure TForm1.CEFLinkedWindowParent1Enter(Sender: TObject);
|
||||
begin
|
||||
If not(csDesigning in ComponentState) then Chromium1.SetFocus(True);
|
||||
end;
|
||||
|
||||
// This is a workaround for the CEF issue #2026
|
||||
// https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on
|
||||
// We use CEFLinkedWindowParent1.OnEnter, CEFLinkedWindowParent1.OnExit and
|
||||
// TChromium.OnGotFocus to avoid most of the focus issues.
|
||||
// CEFLinkedWindowParent1.TabStop must be TRUE.
|
||||
procedure TForm1.CEFLinkedWindowParent1Exit(Sender: TObject);
|
||||
begin
|
||||
if not(csDesigning in ComponentState) then Chromium1.SendCaptureLostEvent;
|
||||
if not(csDesigning in ComponentState) then
|
||||
Chromium1.SendCaptureLostEvent;
|
||||
end;
|
||||
|
||||
procedure TForm1.CEFLinkedWindowParent1Enter(Sender: TObject);
|
||||
begin
|
||||
if not(csDesigning in ComponentState) and
|
||||
Chromium1.Initialized and
|
||||
not(Chromium1.FrameIsFocused) then
|
||||
Chromium1.SendFocusEvent(True);
|
||||
end;
|
||||
|
||||
procedure TForm1.Chromium1GotFocus(Sender: TObject; const browser: ICefBrowser);
|
||||
begin
|
||||
CEFLinkedWindowParent1.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TForm1.BrowserCreatedMsg(Data: PtrInt);
|
||||
|
@ -2,7 +2,7 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 218,
|
||||
"InternalVersion" : 219,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "87.1.12.0"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user