Converting Text To Speech using Javascript Actions in Nanoflow

0
Hi Experts, I converted a particular text into speech using NanoFlow JavaScript Actions. But Now I want to convert a particular selected text which selected by users on the UI into speech. If I clicks a Text to speech button on the UI side then the selected text will converted into Speech. How can I implement this ?  Here I have attached the reference Document which I have used in my previous project. https://docs.mendix.com/howto/extensibility/write-javascript-actions#:~:text=Right%2Dclick%20your%20folder%20in,and%20type%20 Thanks in Advance.
asked
3 answers
0

Hello Shalini,

You can get selected value using following jquery code,

and you have to pass that value into the microflow.

function getSelectedText(el) {
  var sel, range;
  if (typeof el.selectionStart == "number" && typeof el.selectionEnd == "number") {
    return el.value.slice(el.selectionStart, el.selectionEnd);
  } else if (
    (sel = document.selection) &&
    sel.type == "Text" &&
    (range = sel.createRange()).parentElement() == el) {
    return range.text;
  }
  return "";
}

window.onload = function() {
  document.getElementById("ta").onselect = function() {
    alert("Selected text: " + getSelectedText(this));
  };
};
answered
0

Hi,

I am new to Mendix platform. I tried with the above method.But the problem is Before deploying a project into eclipse I am supposed to select the input type in java action call.But how can I give the input Because according to my requirement the input is users  selected text.So what I should select in input field.

Thanks in Advance.

answered
0

Would be easier for a first solution to provide your users a text box where they can copy and paste the text into and convert text to speech by button click. because then you would have the text in an attribute already which you can use and pass to your java

answered