From cc765ced2d87362389c6bff841c4823074fbbc0e Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Sat, 27 Nov 2021 22:20:32 -0500 Subject: [PATCH] move observable to minigui core --- minigui_addons/webview.d | 42 +++------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/minigui_addons/webview.d b/minigui_addons/webview.d index 02d278d..797e4ca 100644 --- a/minigui_addons/webview.d +++ b/minigui_addons/webview.d @@ -14,45 +14,6 @@ version(Windows) version=wv2; -class StateChanged(alias field) : Event { - enum EventString = __traits(identifier, __traits(parent, field)) ~ "." ~ __traits(identifier, field) ~ ":change"; - override bool cancelable() const { return false; } - this(Widget target, typeof(field) newValue) { - this.newValue = newValue; - super(EventString, target); - } - - typeof(field) newValue; -} - -void addWhenTriggered(Widget w, void delegate() dg) { - w.addEventListener("triggered", dg); -} - -mixin template Observable(T, string name) { - private T backing; - - mixin(q{ - void } ~ name ~ q{_changed (void delegate(T) dg) { - this.addEventListener((StateChanged!this_thing ev) { - dg(ev.newValue); - }); - } - - @property T } ~ name ~ q{ () { - return backing; - } - - @property void } ~ name ~ q{ (T t) { - backing = t; - auto event = new StateChanged!this_thing(this, t); - event.dispatch(); - } - }); - - mixin("private alias this_thing = " ~ name ~ ";"); -} - /+ SPA mode: put favicon on top level window, no other user controls at top level, links to different domains always open in new window. +/ @@ -143,6 +104,9 @@ class WebViewWidget_WV2 : WebViewWidgetBase { return S_OK; }); + // add_HistoryChanged + // that's where CanGoBack and CanGoForward can be rechecked. + RC!ICoreWebView2Settings Settings = webview_window.Settings; Settings.IsScriptEnabled = TRUE; Settings.AreDefaultScriptDialogsEnabled = TRUE;