Project

General

Profile

Save button on WTextEdit

Added by Francesco Alfano over 13 years ago

Hello,

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 over 13 years ago

Hey,

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: http://wiki.moxiecode.com/index.php/TinyMCE:API/tinymce.Editor/addButton 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.

    (1-1/1)