mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-16 00:05:55 +01:00
Added DevTools menu option to popup windows in MiniBrowser demo
This commit is contained in:
parent
78adeecde2
commit
5649b6e661
@ -292,7 +292,8 @@ implementation
|
|||||||
{$R *.dfm}
|
{$R *.dfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
uPreferences, uCefStringMultimap, uCEFMiscFunctions, uSimpleTextViewer;
|
uPreferences, uCefStringMultimap, uCEFMiscFunctions, uSimpleTextViewer,
|
||||||
|
uCEFClient;
|
||||||
|
|
||||||
// Destruction steps
|
// Destruction steps
|
||||||
// =================
|
// =================
|
||||||
@ -371,8 +372,8 @@ procedure TMiniBrowserFrm.Chromium1BeforeContextMenu(Sender: TObject;
|
|||||||
const browser: ICefBrowser; const frame: ICefFrame;
|
const browser: ICefBrowser; const frame: ICefFrame;
|
||||||
const params: ICefContextMenuParams; const model: ICefMenuModel);
|
const params: ICefContextMenuParams; const model: ICefMenuModel);
|
||||||
begin
|
begin
|
||||||
if not(Chromium1.IsSameBrowser(browser)) then exit;
|
if Chromium1.IsSameBrowser(browser) then
|
||||||
|
begin
|
||||||
model.AddSeparator;
|
model.AddSeparator;
|
||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_TAKESNAPSHOT, 'Take snapshot...');
|
model.AddItem(MINIBROWSER_CONTEXTMENU_TAKESNAPSHOT, 'Take snapshot...');
|
||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_GETNAVIGATION, 'Get navigation entries');
|
model.AddItem(MINIBROWSER_CONTEXTMENU_GETNAVIGATION, 'Get navigation entries');
|
||||||
@ -398,6 +399,9 @@ begin
|
|||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_UNMUTEAUDIO, 'Unmute audio')
|
model.AddItem(MINIBROWSER_CONTEXTMENU_UNMUTEAUDIO, 'Unmute audio')
|
||||||
else
|
else
|
||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_MUTEAUDIO, 'Mute audio');
|
model.AddItem(MINIBROWSER_CONTEXTMENU_MUTEAUDIO, 'Mute audio');
|
||||||
|
end
|
||||||
|
else
|
||||||
|
model.AddItem(MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS, 'Show DevTools');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PathToMyDocuments : string;
|
function PathToMyDocuments : string;
|
||||||
@ -506,11 +510,13 @@ procedure TMiniBrowserFrm.Chromium1ContextMenuCommand(Sender: TObject;
|
|||||||
eventFlags: Cardinal; out Result: Boolean);
|
eventFlags: Cardinal; out Result: Boolean);
|
||||||
var
|
var
|
||||||
TempParam : WParam;
|
TempParam : WParam;
|
||||||
|
TempInfo : TCefWindowInfo;
|
||||||
|
TempClient : ICefClient;
|
||||||
|
TempSettings : TCefBrowserSettings;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
if not(Chromium1.IsSameBrowser(browser)) then exit;
|
if Chromium1.IsSameBrowser(browser) then
|
||||||
|
|
||||||
case commandId of
|
case commandId of
|
||||||
MINIBROWSER_CONTEXTMENU_HIDEDEVTOOLS :
|
MINIBROWSER_CONTEXTMENU_HIDEDEVTOOLS :
|
||||||
PostMessage(Handle, MINIBROWSER_HIDEDEVTOOLS, 0, 0);
|
PostMessage(Handle, MINIBROWSER_HIDEDEVTOOLS, 0, 0);
|
||||||
@ -567,6 +573,18 @@ begin
|
|||||||
|
|
||||||
MINIBROWSER_CONTEXTMENU_MUTEAUDIO :
|
MINIBROWSER_CONTEXTMENU_MUTEAUDIO :
|
||||||
Chromium1.AudioMuted := True;
|
Chromium1.AudioMuted := True;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
case commandId of
|
||||||
|
MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS :
|
||||||
|
try
|
||||||
|
WindowInfoAsPopUp(TempInfo, browser.Host.WindowHandle, 'DevTools');
|
||||||
|
TempClient := TCustomClientHandler.Create(Chromium1, True);
|
||||||
|
FillChar(TempSettings, SizeOf(TCefBrowserSettings), 0);
|
||||||
|
browser.Host.ShowDevTools(@TempInfo, TempClient, @TempSettings, nil);
|
||||||
|
finally
|
||||||
|
TempClient := nil
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<IsVisibleTab Value="True"/>
|
<IsVisibleTab Value="True"/>
|
||||||
<EditorIndex Value="1"/>
|
<EditorIndex Value="1"/>
|
||||||
<TopLine Value="71"/>
|
<TopLine Value="544"/>
|
||||||
<CursorPos X="3" Y="86"/>
|
<CursorPos X="38" Y="555"/>
|
||||||
<UsageCount Value="21"/>
|
<UsageCount Value="21"/>
|
||||||
<Bookmarks Count="3">
|
<Bookmarks Count="3">
|
||||||
<Item0 Y="822" ID="1"/>
|
<Item0 Y="840" ID="1"/>
|
||||||
<Item1 X="49" Y="61" ID="2"/>
|
<Item1 X="49" Y="61" ID="2"/>
|
||||||
<Item2 X="65" Y="1041" ID="3"/>
|
<Item2 X="65" Y="1059" ID="3"/>
|
||||||
</Bookmarks>
|
</Bookmarks>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
<LoadedDesigner Value="True"/>
|
<LoadedDesigner Value="True"/>
|
||||||
@ -92,11 +92,23 @@
|
|||||||
<UsageCount Value="10"/>
|
<UsageCount Value="10"/>
|
||||||
</Unit8>
|
</Unit8>
|
||||||
</Units>
|
</Units>
|
||||||
<JumpHistory Count="1">
|
<JumpHistory Count="4" HistoryIndex="3">
|
||||||
<Position1>
|
<Position1>
|
||||||
<Filename Value="MiniBrowser.lpr"/>
|
<Filename Value="MiniBrowser.lpr"/>
|
||||||
<Caret Line="65" TopLine="46"/>
|
<Caret Line="65" TopLine="46"/>
|
||||||
</Position1>
|
</Position1>
|
||||||
|
<Position2>
|
||||||
|
<Filename Value="uMiniBrowser.pas"/>
|
||||||
|
<Caret Line="66" Column="75" TopLine="46"/>
|
||||||
|
</Position2>
|
||||||
|
<Position3>
|
||||||
|
<Filename Value="uMiniBrowser.pas"/>
|
||||||
|
<Caret Line="67" Column="39" TopLine="46"/>
|
||||||
|
</Position3>
|
||||||
|
<Position4>
|
||||||
|
<Filename Value="uMiniBrowser.pas"/>
|
||||||
|
<Caret Line="461" TopLine="448"/>
|
||||||
|
</Position4>
|
||||||
</JumpHistory>
|
</JumpHistory>
|
||||||
<RunParams>
|
<RunParams>
|
||||||
<FormatVersion Value="2"/>
|
<FormatVersion Value="2"/>
|
||||||
|
@ -288,7 +288,8 @@ implementation
|
|||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
uPreferences, uCefStringMultimap, uCEFMiscFunctions, uSimpleTextViewer;
|
uPreferences, uCefStringMultimap, uCEFMiscFunctions, uSimpleTextViewer,
|
||||||
|
uCefClient;
|
||||||
|
|
||||||
// Destruction steps
|
// Destruction steps
|
||||||
// =================
|
// =================
|
||||||
@ -427,8 +428,8 @@ procedure TMiniBrowserFrm.Chromium1BeforeContextMenu(Sender: TObject;
|
|||||||
const browser: ICefBrowser; const frame: ICefFrame;
|
const browser: ICefBrowser; const frame: ICefFrame;
|
||||||
const params: ICefContextMenuParams; const model: ICefMenuModel);
|
const params: ICefContextMenuParams; const model: ICefMenuModel);
|
||||||
begin
|
begin
|
||||||
if not(Chromium1.IsSameBrowser(browser)) then exit;
|
if Chromium1.IsSameBrowser(browser) then
|
||||||
|
begin
|
||||||
model.AddSeparator;
|
model.AddSeparator;
|
||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_TAKESNAPSHOT, 'Take snapshot...');
|
model.AddItem(MINIBROWSER_CONTEXTMENU_TAKESNAPSHOT, 'Take snapshot...');
|
||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_GETNAVIGATION, 'Get navigation entries');
|
model.AddItem(MINIBROWSER_CONTEXTMENU_GETNAVIGATION, 'Get navigation entries');
|
||||||
@ -454,6 +455,9 @@ begin
|
|||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_UNMUTEAUDIO, 'Unmute audio')
|
model.AddItem(MINIBROWSER_CONTEXTMENU_UNMUTEAUDIO, 'Unmute audio')
|
||||||
else
|
else
|
||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_MUTEAUDIO, 'Mute audio');
|
model.AddItem(MINIBROWSER_CONTEXTMENU_MUTEAUDIO, 'Mute audio');
|
||||||
|
end
|
||||||
|
else
|
||||||
|
model.AddItem(MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS, 'Show DevTools');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PathToMyDocuments : string;
|
function PathToMyDocuments : string;
|
||||||
@ -546,11 +550,13 @@ procedure TMiniBrowserFrm.Chromium1ContextMenuCommand(Sender: TObject;
|
|||||||
eventFlags: Cardinal; out Result: Boolean);
|
eventFlags: Cardinal; out Result: Boolean);
|
||||||
var
|
var
|
||||||
TempParam : WParam;
|
TempParam : WParam;
|
||||||
|
TempInfo : TCefWindowInfo;
|
||||||
|
TempClient : ICefClient;
|
||||||
|
TempSettings : TCefBrowserSettings;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
if not(Chromium1.IsSameBrowser(browser)) then exit;
|
if Chromium1.IsSameBrowser(browser) then
|
||||||
|
|
||||||
case commandId of
|
case commandId of
|
||||||
MINIBROWSER_CONTEXTMENU_HIDEDEVTOOLS :
|
MINIBROWSER_CONTEXTMENU_HIDEDEVTOOLS :
|
||||||
PostMessage(Handle, MINIBROWSER_HIDEDEVTOOLS, 0, 0);
|
PostMessage(Handle, MINIBROWSER_HIDEDEVTOOLS, 0, 0);
|
||||||
@ -607,6 +613,18 @@ begin
|
|||||||
|
|
||||||
MINIBROWSER_CONTEXTMENU_MUTEAUDIO :
|
MINIBROWSER_CONTEXTMENU_MUTEAUDIO :
|
||||||
Chromium1.AudioMuted := True;
|
Chromium1.AudioMuted := True;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
case commandId of
|
||||||
|
MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS :
|
||||||
|
try
|
||||||
|
WindowInfoAsPopUp(TempInfo, browser.Host.WindowHandle, 'DevTools');
|
||||||
|
TempClient := TCustomClientHandler.Create(Chromium1, True);
|
||||||
|
FillChar(TempSettings, SizeOf(TCefBrowserSettings), 0);
|
||||||
|
browser.Host.ShowDevTools(@TempInfo, TempClient, @TempSettings, nil);
|
||||||
|
finally
|
||||||
|
TempClient := nil
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"UpdateLazPackages" : [
|
"UpdateLazPackages" : [
|
||||||
{
|
{
|
||||||
"ForceNotify" : true,
|
"ForceNotify" : true,
|
||||||
"InternalVersion" : 103,
|
"InternalVersion" : 104,
|
||||||
"Name" : "cef4delphi_lazarus.lpk",
|
"Name" : "cef4delphi_lazarus.lpk",
|
||||||
"Version" : "80.0.4.0"
|
"Version" : "80.0.4.0"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user