Usando ACE con WT

ACTUALIZACIÓN 3 Código de trabajo final a continuación. USTED NECESITA EL ace.js DE LA CARPETA src! No funcionará desde las librerías, necesita la versión preempaquetada de su sitio.

WText *editor = new WText(root());
editor->setText("function(){\n hello.abc();\n}\n");
editor->setInline(false);

El código anterior puede configurar el contenido de la ventana ACE.

MyClass::MyClass(const WEnvironment& env)
: WApplication(env)
{
wApp->require("ace-builds/src/ace.js");
// A WContainerWidget is rendered as a div
WContainerWidget *editor = new WContainerWidget(root());
editor->resize(500, 500);

std::string editor_ref = editor->jsRef(); // is a text string that will be the element when executed in JS

std::string command = 
  editor_ref + ".editor = ace.edit(" + editor_ref + ");" +
  editor_ref + ".editor.setTheme(\"ace/theme/monokai\");" +
  editor_ref + ".editor.getSession().setMode(\"ace/mode/javascript\");";

editor->doJavaScript(command);


JSignal <std::string> *jsignal = new JSignal<std::string>(editor, "textChanged");
jsignal->connect(this, &MyClass::textChanged);

WPushButton *b = new WPushButton("Save", root());

command = "function(object, event) {" +
  jsignal->createCall(editor_ref + ".editor.getValue()") +
  ";}";

b->clicked().connect(command);
}

void MyClass::textChanged(std::string incoming)
{

}

ACTUALIZACIÓN 2 Esto es lo que parece mi proyecto de cajero automático, aún aparece una pantalla blanca con un mensaje rojo "Cargando ..." de WT en la esquina superior derecha. Más notas a continuación.

MyClass::MyClass(const WEnvironment& env)
: WApplication(env)
{
wApp->require("lib/ace/ace.js");
// A WContainerWidget is rendered as a div
WContainerWidget *editor = new WContainerWidget(root());
editor->resize(500, 500);

std::string editor_ref = editor->jsRef(); // is a text string that will be the element when executed in JS

std::string command = 
  editor_ref + ".editor = ace.edit(" + editor_ref + ");" +
  editor_ref + ".editor.setTheme(\"ace/theme/monokai\");" +
  editor_ref + ".editor.getSession().setMode(\"ace/mode/javascript\");";

editor->doJavaScript(command);


JSignal <std::string> *jsignal = new JSignal<std::string>(editor, "textChanged");
jsignal->connect(this, &MyClass::textChanged);

WPushButton *b = new WPushButton("Save", root());

command = "function(object, event) {" +
  jsignal->createCall(editor_ref + ".editor.getValue()") +
  ";}";

b->clicked().connect(command);
}

void MyClass::textChanged(std::string incoming)
{

}

La variable "comando" es igual a la siguiente cuando se usa para editor-> doJavaScript (comando)

"Wt3_3_0.$('oy4ycjy').editor = ace.edit(Wt3_3_0.$('oy4ycjy'));Wt3_3_0.$('oy4ycjy').editor.setTheme('ace/theme/monokai');Wt3_3_0.$('oy4ycjy').editor.getSession().setMode('ace/mode/javascript');"

La variable "command" es igual a la siguiente cuando se usa para b-> clicked (). connect (command);

"function(object, event) {Wt.emit('oy4ycjy','textChanged',Wt3_3_0.$('oy4ycjy').editor.getValue());;}"

ACTUALIZACIÓN 1

Agregué el código sugerido a mi constructor, sin embargo, la página no cambia de una pantalla blanca sólida. No estoy haciendo nada más en este proyecto WT, solo este código se está ejecutando.

wApp->require("lib/ace/ace.js");
// A WContainerWidget is rendered as a div
WContainerWidget *editor = new WContainerWidget(root());
std::string editor_ref = editor->jsRef(); // is a text string that will be the element when executed in JS
editor->doJavaScript(
  editor_ref + ".editor = ace.edit('" + editor_ref + "');" +
  editor_ref + ".editor.setTheme('ace/theme/monokai');" +
  editor_ref + ".editor.getSession().setMode('ace/mode/javascript');"
  );

El valor de editor_ref es "Wt3_3_0. $ ('Oumvrgm')" menos las comillas.

También intenté agregar el código a continuación, y la página aún está en blanco.

JSignal <std::string> *jsignal = new JSignal<std::string>(editor, "textChanged");
jsignal->connect(this, &MyClass::textChanged);

WPushButton *b = new WPushButton("Save", root());
b->clicked().connect("function(object, event) {" +
  jsignal->createCall(editor->jsRef() + ".editor.getValue()") +
  ";}");

También he encontrado que comentar

editor_ref + ".editor = ace.edit('" + editor_ref + "');" +

hace que el botón aparezca, pero hay una nota roja de "Cargando ..." en la parte superior derecha de la pantalla, por lo que WT está esperando algo.

Tengo textChanged como una función de no hacer nada en este momento.

POSTE ORIGINAL

Entonces, mi problema es este. ¿Cómo puedo obtener ACEhttp://ace.ajax.org/#nav=about en WThttp://www.webtoolkit.eu/wt. Más específicamente, ACE en un WT Wt :: WTextArea o Wt :: WTabWidget, se preferiría el área de texto. He intentado hacer esto durante unos días y no he tenido mucho éxito.

He podido incrustar ACE en una página HTML sin ningún problema, ya que su sitio dice "solo cópialo y pégalo en tu página" y es así de simple. Sin embargo, necesito cargarlo localmente a través de WT y en un contenedor. Descargué sus repositorios de GIT a mi máquina y he intentado usar

require("lib/ace/ace.js");

y

doJavaScript(...);

con varios comandos sin éxito ... No soy tan fuerte en Java y HTML como C ++, así que le pediré tantos detalles como sea posible si esto implica una gran cantidad de Java / HTML. Gracias de antemano compañeros!

Respuestas a la pregunta(1)

Su respuesta a la pregunta