Giter Site home page Giter Site logo

Comments (5)

choco avatar choco commented on July 23, 2024

Why the mouseDown event isn't registering ? Have you added your TUITextRenderer to the view text renders array? If you don't do this the event won't propagate ( i think, I''m not sure).

from twui.

mrjjwright avatar mrjjwright commented on July 23, 2024

Yes, I did add this to the textRenderers array. My normal text registers but not the links. I will keep trying, I am probably doing something silly.

from twui.

Naituw avatar Naituw commented on July 23, 2024

atebits said 19 days ago to me ;P :
Check out the delegate methods for TUITextRenderer, you have your delegate supply the ranges that should be clickable, and in your -mouseUp: method (in your view), you can determine the clicked range with the .hitRange property on the text renderer.

this solve my problem, and it is a faster way if you dynamical create AttributedString when you scroll the tableView.

from twui.

mrjjwright avatar mrjjwright commented on July 23, 2024

Sweet, so I will just not use 'NSLinkAttribute' and just use clickable ranges.

On Aug 25, 2011, at 5:37 PM, [email protected] wrote:

atebits said 19 days ago to me ;P :
Check out the delegate methods for TUITextRenderer, you have your delegate supply the ranges that should be clickable, and in your -mouseUp: method (in your view), you can determine the clicked range with the .hitRange property on the text renderer.

Reply to this email directly or view it on GitHub:
#60 (comment)

from twui.

mrjjwright avatar mrjjwright commented on July 23, 2024

I solved this by subclassing TUITextRenderer and overriding mouseUp as so:

- (void)mouseUp:(NSEvent *)event {
    CFIndex i = [self stringIndexForEvent:event];
    NSRange effectiveRange = NSMakeRange(0, 0);
    // Get the attributed string in this index
    id attr = [attributedString attribute:NSLinkAttributeName atIndex:i effectiveRange:&effectiveRange];
    if (attr && [attr isKindOfClass:[NSURL class]]) {
        //Open up the url
        [[NSWorkspace sharedWorkspace] openURL:attr];
    }
    [super mouseUp:event];
}

I will add on code to handle other types of attributes as well specific to my app. Thanks!

from twui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.