Move cursor to end with input elements on QtWebEngine
This commit is contained in:
parent
1e1ba34b60
commit
bc0a9cd94d
@ -29,6 +29,7 @@ Fixed
|
||||
- Fixed the web inspector with QtWebEngine
|
||||
- Version checks when starting qutebrowser now also take the Qt version PyQt was compiled against into account
|
||||
- Hinting a input now doesn't select existing text anymore with QtWebKit
|
||||
- The cursor now moves to the end when input elements are selected with QtWebEngine
|
||||
|
||||
v0.10.0
|
||||
-------
|
||||
|
@ -328,8 +328,7 @@ class AbstractWebElement(collections.abc.MutableMapping):
|
||||
|
||||
def _move_text_cursor(self):
|
||||
"""Move cursor to end after clicking."""
|
||||
if self.is_text_input() and self.is_editable():
|
||||
self._tab.caret.move_to_end_of_document()
|
||||
raise NotImplementedError
|
||||
|
||||
def _click_fake_event(self, click_target):
|
||||
"""Send a fake click event to the element."""
|
||||
|
@ -157,6 +157,12 @@ class WebEngineElement(webelem.AbstractWebElement):
|
||||
self._id)
|
||||
self._tab.run_js_async(js_code)
|
||||
|
||||
def _move_text_cursor(self):
|
||||
if self.is_text_input() and self.is_editable():
|
||||
js_code = javascript.assemble('webelem', 'move_cursor_to_end',
|
||||
self._id)
|
||||
self._tab.run_js_async(js_code)
|
||||
|
||||
def _click_editable(self, click_target):
|
||||
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-58515
|
||||
# pylint doesn't know about Qt.MouseEventSynthesizedBySystem
|
||||
@ -171,6 +177,7 @@ class WebEngineElement(webelem.AbstractWebElement):
|
||||
# This actually "clicks" the element by calling focus() on it in JS.
|
||||
js_code = javascript.assemble('webelem', 'focus', self._id)
|
||||
self._tab.run_js_async(js_code)
|
||||
self._move_text_cursor()
|
||||
|
||||
def _click_js(self, _click_target):
|
||||
settings = QWebEngineSettings.globalSettings()
|
||||
|
@ -300,6 +300,10 @@ class WebKitElement(webelem.AbstractWebElement):
|
||||
break
|
||||
elem = elem._parent() # pylint: disable=protected-access
|
||||
|
||||
def _move_text_cursor(self):
|
||||
if self.is_text_input() and self.is_editable():
|
||||
self._tab.caret.move_to_end_of_document()
|
||||
|
||||
def _click_editable(self, click_target):
|
||||
ok = self._elem.evaluateJavaScript('this.focus(); true;')
|
||||
if ok:
|
||||
|
@ -203,5 +203,11 @@ window._qutebrowser.webelem = (function() {
|
||||
elem.focus();
|
||||
};
|
||||
|
||||
funcs.move_cursor_to_end = function(id) {
|
||||
var elem = elements[id];
|
||||
elem.selectionStart = elem.value.length;
|
||||
elem.selectionEnd = elem.value.length;
|
||||
};
|
||||
|
||||
return funcs;
|
||||
})();
|
||||
|
@ -188,7 +188,6 @@ Feature: Using hints
|
||||
And I run :hint
|
||||
Then the error "No elements found." should be shown
|
||||
|
||||
@qtwebengine_todo: Doesn't move the cursor to the end
|
||||
Scenario: Clicking input with existing text
|
||||
When I set general -> log-javascript-console to info
|
||||
And I open data/hints/input.html
|
||||
|
@ -48,12 +48,6 @@ def test_insert_mode(file_name, elem_id, source, input_text, auto_insert, zoom,
|
||||
if source == 'keypress':
|
||||
quteproc.press_keys(input_text)
|
||||
elif source == 'clipboard':
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: caret mode is not "
|
||||
"implemented")
|
||||
# Note we actually run the keypress tests with QtWebEngine, as for
|
||||
# some reason it selects all the text when clicking the field the
|
||||
# second time.
|
||||
quteproc.send_cmd(':debug-set-fake-clipboard "{}"'.format(input_text))
|
||||
quteproc.send_cmd(':insert-text {clipboard}')
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user