Fix focusing IV content.
This commit is contained in:
parent
5f3c380d56
commit
0a87dbea68
|
@ -135,6 +135,9 @@ html.custom_scroll ::-webkit-scrollbar-thumb:hover {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
.page-scroll:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
.page-slide {
|
.page-slide {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -79,10 +79,14 @@ var IV = {
|
||||||
});
|
});
|
||||||
} else if (e.key === 'Escape' || e.keyCode === 27) {
|
} else if (e.key === 'Escape' || e.keyCode === 27) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
IV.notify({
|
if (IV.position) {
|
||||||
event: 'keydown',
|
window.history.back();
|
||||||
key: 'escape',
|
} else {
|
||||||
});
|
IV.notify({
|
||||||
|
event: 'keydown',
|
||||||
|
key: 'escape',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
frameMouseEnter: function (e) {
|
frameMouseEnter: function (e) {
|
||||||
|
@ -250,6 +254,8 @@ var IV = {
|
||||||
}
|
}
|
||||||
IV.initMedia();
|
IV.initMedia();
|
||||||
IV.notify({ event: 'ready' });
|
IV.notify({ event: 'ready' });
|
||||||
|
|
||||||
|
IV.forceScrollFocus();
|
||||||
},
|
},
|
||||||
initMedia: function () {
|
initMedia: function () {
|
||||||
const photos = document.getElementsByClassName('photo');
|
const photos = document.getElementsByClassName('photo');
|
||||||
|
@ -356,6 +362,7 @@ var IV = {
|
||||||
var data = JSON.parse(IV.cache[index].content);
|
var data = JSON.parse(IV.cache[index].content);
|
||||||
var el = document.createElement('div');
|
var el = document.createElement('div');
|
||||||
el.className = 'page-scroll';
|
el.className = 'page-scroll';
|
||||||
|
el.tabIndex = '-1';
|
||||||
el.innerHTML = '<div class="page-slide"><article>'
|
el.innerHTML = '<div class="page-slide"><article>'
|
||||||
+ data.html
|
+ data.html
|
||||||
+ '</article></div>';
|
+ '</article></div>';
|
||||||
|
@ -370,6 +377,7 @@ var IV = {
|
||||||
IV.pending = null;
|
IV.pending = null;
|
||||||
if (IV.index == index) {
|
if (IV.index == index) {
|
||||||
IV.jumpToHash(hash, IV.mac);
|
IV.jumpToHash(hash, IV.mac);
|
||||||
|
IV.forceScrollFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.history.replaceState(IV.computeCurrentState(), '');
|
window.history.replaceState(IV.computeCurrentState(), '');
|
||||||
|
@ -452,6 +460,15 @@ var IV = {
|
||||||
} else {
|
} else {
|
||||||
IV.jumpToHash(hash, IV.mac);
|
IV.jumpToHash(hash, IV.mac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IV.forceScrollFocus();
|
||||||
|
},
|
||||||
|
forceScrollFocus: function () {
|
||||||
|
IV.findPageScroll().focus();
|
||||||
|
setTimeout(function () {
|
||||||
|
// Doesn't work on #hash-ed pages in Windows WebView2 otherwise.
|
||||||
|
IV.findPageScroll().focus();
|
||||||
|
}, 100);
|
||||||
},
|
},
|
||||||
back: function () {
|
back: function () {
|
||||||
window.history.back();
|
window.history.back();
|
||||||
|
@ -467,9 +484,9 @@ document.onkeydown = IV.frameKeyDown;
|
||||||
document.onmouseenter = IV.frameMouseEnter;
|
document.onmouseenter = IV.frameMouseEnter;
|
||||||
document.onmouseup = IV.frameMouseUp;
|
document.onmouseup = IV.frameMouseUp;
|
||||||
window.onmessage = IV.postMessageHandler;
|
window.onmessage = IV.postMessageHandler;
|
||||||
|
|
||||||
window.addEventListener('popstate', function (e) {
|
window.addEventListener('popstate', function (e) {
|
||||||
if (e.state) {
|
if (e.state) {
|
||||||
IV.showDOM(e.state.index, e.state.hash, e.state.scroll);
|
IV.showDOM(e.state.index, e.state.hash, e.state.scroll);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
document.addEventListener("DOMContentLoaded", IV.forceScrollFocus);
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/invoke_queued.h"
|
#include "base/invoke_queued.h"
|
||||||
|
#include "base/qt_signal_producer.h"
|
||||||
#include "iv/iv_data.h"
|
#include "iv/iv_data.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/platform/ui_platform_window_title.h"
|
#include "ui/platform/ui_platform_window_title.h"
|
||||||
|
@ -31,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtCore/QJsonValue>
|
#include <QtCore/QJsonValue>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
|
#include <QtGui/QWindow>
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
|
|
||||||
namespace Iv {
|
namespace Iv {
|
||||||
|
@ -182,7 +184,7 @@ namespace {
|
||||||
<path d="M14.9972363,18 L9.13865768,12.1414214 C9.06055283,12.0633165 9.06055283,11.9366835 9.13865768,11.8585786 L14.9972363,6 L14.9972363,6" transform="translate(11.997236, 12.000000) scale(-1, -1) rotate(-90.000000) translate(-11.997236, -12.000000) "></path>
|
<path d="M14.9972363,18 L9.13865768,12.1414214 C9.06055283,12.0633165 9.06055283,11.9366835 9.13865768,11.8585786 L14.9972363,6 L14.9972363,6" transform="translate(11.997236, 12.000000) scale(-1, -1) rotate(-90.000000) translate(-11.997236, -12.000000) "></path>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<div class="page-scroll"><div class="page-slide">
|
<div class="page-scroll" tabindex="-1"><div class="page-slide">
|
||||||
<article)"_q + contentAttributes + ">"_q + page.content + R"(</article>
|
<article)"_q + contentAttributes + ">"_q + page.content + R"(</article>
|
||||||
</div></div>
|
</div></div>
|
||||||
<script>)"_q + js + R"(</script>
|
<script>)"_q + js + R"(</script>
|
||||||
|
@ -286,6 +288,15 @@ void Controller::createWindow() {
|
||||||
_window->setTitleStyle(st::ivTitle);
|
_window->setTitleStyle(st::ivTitle);
|
||||||
const auto window = _window.get();
|
const auto window = _window.get();
|
||||||
|
|
||||||
|
base::qt_signal_producer(
|
||||||
|
window->window()->windowHandle(),
|
||||||
|
&QWindow::activeChanged
|
||||||
|
) | rpl::filter([=] {
|
||||||
|
return _webview && window->window()->windowHandle()->isActive();
|
||||||
|
}) | rpl::start_with_next([=] {
|
||||||
|
_webview->focus();
|
||||||
|
}, window->lifetime());
|
||||||
|
|
||||||
_title = std::make_unique<Ui::RpWidget>(window);
|
_title = std::make_unique<Ui::RpWidget>(window);
|
||||||
_title->setAttribute(Qt::WA_TransparentForMouseEvents);
|
_title->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
_title->paintRequest() | rpl::start_with_next([=](QRect clip) {
|
_title->paintRequest() | rpl::start_with_next([=](QRect clip) {
|
||||||
|
@ -521,6 +532,7 @@ void Controller::showInWindow(const QString &dataPath, Prepared page) {
|
||||||
id += '#' + hash;
|
id += '#' + hash;
|
||||||
}
|
}
|
||||||
_webview->navigateToData(id);
|
_webview->navigateToData(id);
|
||||||
|
_webview->focus();
|
||||||
} else {
|
} else {
|
||||||
_events.fire({ Event::Type::Close });
|
_events.fire({ Event::Type::Close });
|
||||||
}
|
}
|
||||||
|
@ -529,12 +541,14 @@ void Controller::showInWindow(const QString &dataPath, Prepared page) {
|
||||||
_window->raise();
|
_window->raise();
|
||||||
_window->activateWindow();
|
_window->activateWindow();
|
||||||
_window->setFocus();
|
_window->setFocus();
|
||||||
|
_webview->focus();
|
||||||
} else {
|
} else {
|
||||||
_navigateToIndexWhenReady = index;
|
_navigateToIndexWhenReady = index;
|
||||||
_navigateToHashWhenReady = hash;
|
_navigateToHashWhenReady = hash;
|
||||||
_window->raise();
|
_window->raise();
|
||||||
_window->activateWindow();
|
_window->activateWindow();
|
||||||
_window->setFocus();
|
_window->setFocus();
|
||||||
|
_webview->focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue