0

In pyqt6 QWebEngineView I load an url (e.g: w3schools modal) on Windows 10 (input: touch screen, without keyboard)

My problem is that, when the user open a Modal (like in the link), and if it has an input field the Windows 10 virtual keyboard shows properly. When the user touch on the Close icon (on the virtual keyboard), the keyboard disappear properly. But when the user touch the screen again the virtual keyboard shows again, but there is no input field.

I have tried the catch the events like focus, toucing but it doesnt help.

GIF


from PyQt6.QtCore import QUrl, Qt

from PyQt6.QtWebEngineCore import QWebEngineProfile, QWebEngineSettings, QWebEnginePage
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtWidgets import QApplication

import sys
import ctypes

base_url = "https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_modal"
version = "1.10"


class SWindow(QWebEngineView):
    def __init__(self, windows, parent=None):
        super(SWindow, self).__init__(parent)
        self.myPage = SPage(self)
        self.setPage(self.myPage)
        self._windows = windows
        self._windows.append(self)
        self.setAttribute(Qt.WidgetAttribute.WA_AcceptTouchEvents, True)


        profile = QWebEngineProfile.defaultProfile()
        profile.setPersistentCookiesPolicy(QWebEngineProfile.PersistentCookiesPolicy.ForcePersistentCookies)

        settings = profile.settings()
        settings.setAttribute(QWebEngineSettings.WebAttribute.JavascriptCanAccessClipboard, True)
        settings.setAttribute(QWebEngineSettings.WebAttribute.JavascriptCanOpenWindows, True)
        settings.setAttribute(QWebEngineSettings.WebAttribute.JavascriptCanAccessClipboard, True)
        settings.setAttribute(QWebEngineSettings.WebAttribute.LocalStorageEnabled, True)
        settings.setAttribute(QWebEngineSettings.WebAttribute.LocalContentCanAccessRemoteUrls, True)
        settings.setAttribute(QWebEngineSettings.WebAttribute.LocalContentCanAccessFileUrls, True)
        settings.setAttribute(QWebEngineSettings.WebAttribute.FullScreenSupportEnabled, True)
        settings.setAttribute(QWebEngineSettings.WebAttribute.AllowRunningInsecureContent, True)

        self.load(QUrl.fromUserInput(base_url))
        self.showMaximized()


class SPage(QWebEnginePage):
    def triggerAction(self, action, checked=False):
        if action == QWebEnginePage.WebAction.OpenLinkInNewWindow:
            self.createWindow(QWebEnginePage.WebAction.WebBrowserWindow)
        return super(SPage, self).triggerAction(action, checked)



if __name__ == "__main__":
    ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('test.desktop.app')
    app = QApplication(sys.argv)
    app.setAttribute(Qt.ApplicationAttribute.AA_SynthesizeMouseForUnhandledTouchEvents, True)
    app.setAttribute(Qt.ApplicationAttribute.AA_SynthesizeMouseForUnhandledTabletEvents, True)

    windows = []
    window = SWindow(windows)

    window.show()

    sys.exit(app.exec())
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Haroshow
  • 5
  • 3
  • What do you mean by "there is no input field"? And how did you try to get those events? Please provide a [mre]. – musicamante Aug 14 '23 at 16:11

0 Answers0