Skip to content

Commit

Permalink
feat(shell):Show document title in WebWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
BalassaMarton committed Feb 28, 2024
1 parent 41b1349 commit c034ba5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/shell/dotnet/Shell.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ regarding copyright ownership. Unless required by applicable law or agreed
to in writing, software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing permissions
and limitations under the License.</s:String></wpf:ResourceDictionary>
and limitations under the License.</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECodeCleanup_002EFileHeader_002EFileHeaderSettingsMigrate/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
11 changes: 10 additions & 1 deletion src/shell/dotnet/Shell/WebWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,20 @@ private Task InitializeCoreWebView2(CoreWebView2 coreWebView)
{
coreWebView.NewWindowRequested += (sender, args) => OnNewWindowRequested(args);
coreWebView.WindowCloseRequested += (sender, args) => OnWindowCloseRequested(args);
coreWebView.NavigationStarting += (sender, args) => OnNavigationStarting(args);
coreWebView.NavigationStarting += (sender, args) => OnNavigationStarting(args);
coreWebView.DocumentTitleChanged += (sender, args) => OnDocumentTitleChanged(args);

return Task.CompletedTask;
}

private void OnDocumentTitleChanged(object args)
{
if (_options.Title == null)
{
Title = WebView.CoreWebView2.DocumentTitle;
}
}

private void OnNavigationStarting(CoreWebView2NavigationStartingEventArgs args)
{
if (_scriptsInjected)
Expand Down
2 changes: 1 addition & 1 deletion src/shell/dotnet/Shell/WebWindowOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed class WebWindowOptions
public double? Width { get; set; }

public const double DefaultHeight = 450;
public const string DefaultTitle = "Compose Web Container";
public const string DefaultTitle = "ComposeUI Web Container";
public const string DefaultUrl = "about:blank";
public const double DefaultWidth = 800;
public const string ParameterName = nameof(WebWindowOptions);
Expand Down

0 comments on commit c034ba5

Please sign in to comment.