Skip to content

Commit

Permalink
Fix problem with arrow navigation
Browse files Browse the repository at this point in the history
For some reason the arrow navigation stopped working, this adds
some workarounds to make it workable again.
  • Loading branch information
jeena committed Sep 11, 2018
1 parent 0a195f8 commit 11524e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 5 additions & 4 deletions html/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,18 @@
else document.body.className = "";
}

document.onkeydown = checkKey;

function checkKey(e) {
e = e || window.event;
if (e.keyCode === '37') {
if (e.keyCode === 37) {
window.location.href = "feedthemonkey:previous";
}
else if (e.keyCode === '39') {
else if (e.keyCode === 39) {
window.location.href = "feedthemonkey:next";
}
}

window.addEventListener("keydown", checkKey);

</script>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
</head>
Expand Down
10 changes: 6 additions & 4 deletions qml/Content.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with FeedTheMonkey. If not, see <http://www.gnu.org/licenses/>.
*/

import QtWebEngine 1.0
import QtWebEngine 1.7
import QtQuick 2.0
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
Expand Down Expand Up @@ -87,12 +87,14 @@ Item {

onNavigationRequested: {
if (request.url == "feedthemonkey:previous") {
request.action = WebEngineView.IgnoreRequest;
// This is commented out because for some reason this reloads the page forever.
// This will show the error that the feedthemonkey:previous location is not supported
//request.action = WebEngineNavigationRequest.IgnoreRequest;
app.showPreviousPost();
} else if (request.url == "feedthemonkey:next") {
request.action = WebEngineView.IgnoreRequest;
//request.action = WebEngineNavigationRequest.IgnoreRequest;
app.showNextPost();
} else if (request.navigationType != WebEngineView.LinkClickedNavigation) {
} else if (request.navigationType !== WebEngineNavigationRequest.LinkClickedNavigation) {
request.action = WebEngineView.AcceptRequest;
} else {
request.action = WebEngineView.IgnoreRequest;
Expand Down

0 comments on commit 11524e9

Please sign in to comment.