Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Adding three ... at the end of string (Read 3896 times)
Shafi
Full Member
***
Offline


I Love MindFusion!

Posts: 109
Joined: Nov 8th, 2016
Adding three ... at the end of string
Aug 30th, 2017 at 7:13am
Print Post  
Hi

I have a requirement that whenever text in shape node bigger that the length of shape node. it must not wrap and also  it must add the three dot at the end of string (...). How can we achieve this?

Thanks
Ankur Shah
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Adding three ... at the end of string
Reply #1 - Aug 30th, 2017 at 8:25am
Print Post  
Hi,

Wrapping cannot be disabled at this time, we'll try to add a property for upcoming release. Until it's available, you could try overriding the wrapping function as shown here -
https://mindfusion.eu/Forum/YaBB.pl?num=1415114615/3#3

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Shafi
Full Member
***
Offline


I Love MindFusion!

Posts: 109
Joined: Nov 8th, 2016
Re: Adding three ... at the end of string
Reply #2 - Aug 30th, 2017 at 9:07am
Print Post  
Hi Slavcho

Thanks for reply
As i am working on Angular 2. Can you please provide me an example in Angular ?

Please have look at my code
Code (Javascript)
Select All
const row = this.factory.createShapeNode(x, y, 10, 10);
row.setText("Some dummy text in shape node");
 


After creating this node i am attaching this node to one of my container.

Thanks
Ankur Shah
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Adding three ... at the end of string
Reply #3 - Aug 30th, 2017 at 11:27am
Print Post  
Hi,

That override can be done like this in TypeScript -

Code
Select All
import mText = MindFusion.Drawing.Text;

declare module MindFusion.Drawing
{
    interface Text
    {
        getLines(context: CanvasRenderingContext2D, rect: Rect): Array<string>;
    }
}

var originalGetLines = mText.prototype.getLines;
mText.prototype.getLines = function (context: CanvasRenderingContext2D, rect: Rect): Array<string>
{
    var wrappedLines = originalGetLines.apply(this, [context, rect]);
    if (wrappedLines.length < 2)
        return wrappedLines;

    var line = wrappedLines[0];
    line += " ...";
    this.lines = [line];
    return this.lines;
}; 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Shafi
Full Member
***
Offline


I Love MindFusion!

Posts: 109
Joined: Nov 8th, 2016
Re: Adding three ... at the end of string
Reply #4 - Sep 4th, 2017 at 7:28am
Print Post  
Thanks Slavcho. It works

But i need to add the below definition in our file index.d.ts. Can you please add it in index.d.ts so that it gets integrated with node module.

getLines(context: CanvasRenderingContext2D, rect: Rect): Array<string>;
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Adding three ... at the end of string
Reply #5 - Sep 6th, 2017 at 9:05am
Print Post  
Anything wrong using interface declaration merging as above? d.ts will be available with 3.1 release in a few days.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Adding three ... at the end of string
Reply #6 - Sep 8th, 2017 at 11:06am
Print Post  
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint