Support #631
closedCreate a WTextEdit under Wdialog
0%
Description
Hello,
i need to create a WTextEdit under a Wdialog. I've used a code like:
TextEditorDialog::TextEditorDialog()
: WDialog("Text Editor Dialog...")
{
int row = 0;
resize(800, 600);
WGridLayout *layout = new WGridLayout();
WContainerWidget *teContainer = new WContainerWidget();
teTextEditor = new Wt::WTextEdit(teContainer);
// Customizing the toolbar(s)
std::string strCfg = teTextEditor->toolBar(0);
strCfg += ",|,mysave";
teTextEditor->setToolBar(0, strCfg);
WApplication::instance()doJavaScript(teTextEditor>jsRef() + ".ed.addButton('mysave', {title: 'Salva su server', image: 'myimage/save01.png', onclick : function() { " + teTextEditor->jsRef() + ".ed.windowManager.alert('Dovrei salvare i dati su server')" +\" } });\");
layout->addWidget(teContainer, row, 0, 0, 3, AlignCenter);
row;
...
other objects ....
show();
}
but it doesn't work, the display is freezed.
Thanks in advance for your help.
Updated by Francesco Alfano over 13 years ago
The problem is when I've add a my save toolbar icon. Without save icon, it works.
With save icon I've, after some time, a Wt internal error: TypeError: j255 .
Thanks for your help.
Updated by Koen Deforche over 13 years ago
- Status changed from New to Resolved
Hey Fransesco,
You need to delay the JavaScript like this - so that the TinyMCE editor itself is created first.
WApplication::instance()->doJavaScript("setTimeout(function() { " + teTextEditor->jsRef() + ".ed.addButton('mysave', {title: 'Salva su server', image: 'save01.png', onclick : function() { " + teTextEditor->jsRef() + ".ed.windowManager.alert('Dovrei salvare i dati su server')" +" } }) }, 0);");
Regards,
koen
Updated by Francesco Alfano over 13 years ago
Hello,
i've tried and your code works, but only one time. When i re-call my TextEditorDialog the save icon doesn't appear ?
Why ?
Thanks for your help.
Updated by Koen Deforche over 13 years ago
Changing the JavaScript to the following apparently works: I did not find any info on why TinyMCE behaves like this:
setTimeout(function() { var ed=" + teTextEditor->jsRef() + ".ed; ed.addButton('mysave', {title: 'Salva su server', image: 'save01.png', onclick : function() { ed.windowManager.alert('Dovrei salvare i dati su server')" +" } }); ed.hide(); ed.render(); }, 0);
Updated by Francesco Alfano over 13 years ago
Many thanks for your help,
i've tried
WApplication::instance()doJavaScript("setTimeout(function() { var ed=" + teTextEditor>jsRef() + ".ed; ed.addButton('mysave', {title: 'Salva su server', image: 'myimage/save01.png', onclick : function() { ed.windowManager.alert('Dovrei salvare i dati su server')" +\" } }); ed.hide(); ed.render(); }, 0);\");
and it's works fine.
Updated by Francesco Alfano over 13 years ago
Ops, there is a mistake, the save icons i present but i can't write to text on editor it seems to be read only.
I'm sorry for previous post.
Updated by Koen Deforche about 13 years ago
- Status changed from Resolved to Closed