Jump to content

UniCanvas doesn't have TextOut function?


stlcours

Recommended Posts

  • 4 years later...
//Delphi
UniSession.AddJS(unicanvas.JSName + '._cc_.fillText("'+text+'",'+left+','+top+');');

//C++
UnicodeString s = UnicodeString().sprintf(L"%s._cc_.fillText('%s',%d,%d);", unicanvas->JSName, text, left, top);
UniSession()->AddJS(s);

Of course, is better if you do some escaping of the text first, otherwise you will be open to injection

Link to comment
Share on other sites

  • 1 year later...
2 hours ago, Bluecollar said:

How can i change the text color with the fillText function ?

Hello,

One possible solution:

Uses ... , UniGUIJSUtils;

procedure TMainForm.UniButton14Click(Sender: TObject);
begin
  UniCanvas1.JSInterface.JSCode('var me='#1'._cc_; if (me) {me.fillStyle="'+ uniColor2Web(clGreen, 1) +'"; me.font="20px sans-serif"; me.fillText("test", 100, 100)};');
end;

 

  • Like 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...