mholmes
16th January 2012, 13:23
Hi there,
I'm building a rudimentary WYSIWYG/code editor widget based on Webkit
and the contenteditable attribute, and I'm finding it quite
straightforward so far. However, there's one issue I can't figure out.
To toggle bold text (for example), it's sufficient to do this:
webView->triggerPageAction(QWebPage::ToggleBold);
However, I would also like to be able to make my menu items and toolbar
buttons reflect the state of the text under the cursor, so that (for
instance) if the cursor is on bold text, the Bold toolbar button would
be pressed and the menu item would be checked. This is clearly possible,
because the default context menu provided the webkit instance works this
way, but I can't find out how to read the state of the current text from
the control.
I found this example project:
http://labs.qt.nokia.com/2009/03/12/wysiwyg-html-editor/
which looks like it might show me what I need, but the codebase is no
longer available; it was in the Trolltech git repository, which is no
longer there, and I can't find it in the qt-project.org git repo.
Can anyone suggest a solution to this, or, failing that, show me where I
might find the wysiwyg-html-editor project?
All help appreciated,
Martin
I'm building a rudimentary WYSIWYG/code editor widget based on Webkit
and the contenteditable attribute, and I'm finding it quite
straightforward so far. However, there's one issue I can't figure out.
To toggle bold text (for example), it's sufficient to do this:
webView->triggerPageAction(QWebPage::ToggleBold);
However, I would also like to be able to make my menu items and toolbar
buttons reflect the state of the text under the cursor, so that (for
instance) if the cursor is on bold text, the Bold toolbar button would
be pressed and the menu item would be checked. This is clearly possible,
because the default context menu provided the webkit instance works this
way, but I can't find out how to read the state of the current text from
the control.
I found this example project:
http://labs.qt.nokia.com/2009/03/12/wysiwyg-html-editor/
which looks like it might show me what I need, but the codebase is no
longer available; it was in the Trolltech git repository, which is no
longer there, and I can't find it in the qt-project.org git repo.
Can anyone suggest a solution to this, or, failing that, show me where I
might find the wysiwyg-html-editor project?
All help appreciated,
Martin