Save button on WTextEdit

Added by Francesco Alfano about 13 years ago


How can i add a "save as" button on WTextEdit and then connect this button to an event ?

Thanks for your help.

Replies (1)

RE: Save button on WTextEdit - Added by Koen Deforche about 13 years ago


It isn't documented but, you can use editor->jsRef() + ".ed" to access the TinyMCE editor instance. Since the standard 'save' button does not do what you hope it would do, you'll need to add your own save button.

With that, and using the API described at: you could do something like:

 // Customizing the toolbar(s)
  std::string strCfg = editor->toolBar(0);
  strCfg += ",|,mysave";
  editor->setToolBar(0, strCfg);

  WApplication::instance()->doJavaScript(editor->jsRef() + ".ed.addButton('mysave', {title: 'save.save_desc', image: 'save.png', onclick : function() { " + saveSignal_.createCall() + " } });");

The saveSignal_ object is then a JSignal<> to which you connect a C function which is called when the user clicks the save button.