Revision: 29465
http://sourceforge.net/p/bibdesk/svn/29465
Author: hofman
Date: 2025-08-25 09:33:37 +0000 (Mon, 25 Aug 2025)
Log Message:
-----------
bind back/forward buttons target and enabled
Modified Paths:
--------------
trunk/bibdesk/BDSKTextImportController.m
trunk/bibdesk/Base.lproj/TextImport.xib
Modified: trunk/bibdesk/BDSKTextImportController.m
===================================================================
--- trunk/bibdesk/BDSKTextImportController.m 2025-08-25 09:18:25 UTC (rev
29464)
+++ trunk/bibdesk/BDSKTextImportController.m 2025-08-25 09:33:37 UTC (rev
29465)
@@ -643,22 +643,19 @@
WKUserScript *script = [[WKUserScript alloc] initWithSource:jsSource
injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO];
[userController addUserScript:script];
+ [self willChangeValueForKey:@"webView"];
+
webView = [[BDSKWKWebView alloc] initWithFrame:[webViewBox bounds]
configuration:config];
[webView setNavigationDelegate:self];
[webView setUIDelegate:self];
+ [self didChangeValueForKey:@"webView"];
+
[webViewBox setEdges:BDSKEveryEdgeMask];
[webViewBox setBackgroundColors:nil];
[webViewBox setBackgroundView:nil];
[webViewBox setContentView:webView];
- [backButton setTarget:webView];
- [backButton setAction:@selector(goBack:)];
- [forwardButton setTarget:webView];
- [forwardButton setAction:@selector(goForward:)];
-
- [webView addObserver:self forKeyPath:@"canGoBack" options:0
context:&BDSKTextImportWebViewObservationContext];
- [webView addObserver:self forKeyPath:@"canGoForward" options:0
context:&BDSKTextImportWebViewObservationContext];
[webView addObserver:self forKeyPath:@"loading" options:0
context:&BDSKTextImportWebViewObservationContext];
}
@@ -670,11 +667,7 @@
[[[webView configuration] userContentController]
removeScriptMessageHandlerForName:@"selectionChanged"];
[[[webView configuration] userContentController] removeAllUserScripts];
- @try {
- [webView removeObserver:self forKeyPath:@"canGoBack"
context:&BDSKTextImportWebViewObservationContext];
- [webView removeObserver:self forKeyPath:@"canGoForward"
context:&BDSKTextImportWebViewObservationContext];
- [webView removeObserver:self forKeyPath:@"loading"
context:&BDSKTextImportWebViewObservationContext];
- }
+ @try { [webView removeObserver:self forKeyPath:@"loading"
context:&BDSKTextImportWebViewObservationContext]; }
@catch (id e) {}
}
@@ -1629,12 +1622,7 @@
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
if (context == &BDSKTextImportWebViewObservationContext) {
- if ([keyPath isEqualToString:@"loading"])
- [self setLoading:[webView isLoading]];
- else if ([keyPath isEqualToString:@"canGoBack"])
- [backButton setEnabled:[webView canGoBack]];
- else if ([keyPath isEqualToString:@"canGoForward"])
- [forwardButton setEnabled:[webView canGoForward]];
+ [self setLoading:[webView isLoading]];
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change
context:context];
}
Modified: trunk/bibdesk/Base.lproj/TextImport.xib
===================================================================
--- trunk/bibdesk/Base.lproj/TextImport.xib 2025-08-25 09:18:25 UTC (rev
29464)
+++ trunk/bibdesk/Base.lproj/TextImport.xib 2025-08-25 09:33:37 UTC (rev
29465)
@@ -518,6 +518,14 @@
<string key="keyEquivalent">[</string>
<modifierMask key="keyEquivalentModifierMask"
command="YES"/>
</buttonCell>
+ <connections>
+ <binding destination="-2" name="enabled"
keyPath="webView.canGoBack" id="qpF-iK-rwS"/>
+ <binding destination="-2" name="target"
keyPath="webView" id="023-ur-4YU">
+ <dictionary key="options">
+ <string key="NSSelectorName">goBack:</string>
+ </dictionary>
+ </binding>
+ </connections>
</button>
<progressIndicator toolTip="Page is loading…" wantsLayer="YES"
horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="100"
displayedWhenStopped="NO" bezeled="NO" indeterminate="YES" controlSize="small"
style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="178">
<rect key="frame" x="277" y="261" width="16" height="16"/>
@@ -542,6 +550,14 @@
<string key="keyEquivalent">]</string>
<modifierMask key="keyEquivalentModifierMask"
command="YES"/>
</buttonCell>
+ <connections>
+ <binding destination="-2" name="enabled"
keyPath="webView.canGoForward" id="AL1-rf-Z2H"/>
+ <binding destination="-2" name="target"
keyPath="webView" id="uf2-VY-M6v">
+ <dictionary key="options">
+ <string
key="NSSelectorName">goForward:</string>
+ </dictionary>
+ </binding>
+ </connections>
</button>
</subviews>
<constraints>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit