Move cursor to end of textboxes when hinting.

This commit is contained in:
Florian Bruhin 2015-02-25 19:56:03 +01:00
parent 9d716d74b4
commit 0fcd016427
2 changed files with 13 additions and 1 deletions

View File

@ -24,10 +24,12 @@ import functools
import subprocess
import collections
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QEvent, Qt, QUrl
from PyQt5.QtCore import (pyqtSignal, pyqtSlot, QObject, QEvent, Qt, QUrl,
QTimer)
from PyQt5.QtGui import QMouseEvent, QClipboard
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebKit import QWebElement
from PyQt5.QtWebKitWidgets import QWebPage
from qutebrowser.config import config
from qutebrowser.keyinput import modeman, modeparsers
@ -392,6 +394,10 @@ class HintManager(QObject):
]
for evt in events:
self.mouse_event.emit(evt)
if elem.is_text_input() and elem.is_editable():
QTimer.singleShot(0, functools.partial(
elem.webFrame().page().triggerAction,
QWebPage.MoveToEndOfDocument))
def _yank(self, url, context):
"""Yank an element to the clipboard or primary selection.

View File

@ -277,6 +277,12 @@ class WebElementWrapper(collections.abc.MutableMapping):
else:
return False
def is_text_input(self):
"""Check if this element is some kind of text box."""
roles = ('combobox', 'textbox')
tag = self._elem.tagName().lower()
return self.get('role', None) in roles or tag in ('input', 'textarea')
def debug_text(self):
"""Get a text based on an element suitable for debug output."""
self._check_vanished()