Giter VIP home page Giter VIP logo

Comments (9)

ryanmcgrath avatar ryanmcgrath commented on July 20, 2024

Yup, this is pretty much just a case of those things not being necessarily ported yet. You probably want an approach that's a mix of 1 and 2.

If you look at e.g view/mod.rs and view/appkit.rs you can begin to see how I tend to wrap these things with regards to the delegate pattern and associated callback linking. I don't have the time at the moment to do this myself, but if you give it a whirl and have questions, feel free to use this issue as a tracking document or make a PR eventually. :)

(If view seems overly complex at the moment, text/label/mod.rs & text/label/appkit.rs might be more digestable~)

from cacao.

jasoneveleth avatar jasoneveleth commented on July 20, 2024

Sorry it took me so long to follow up. I think I've taken on too much at once (rust, mac os api, and ui/ux).

I tried to copy the code from examples/text_input.rs to make a very similar example for the TextView. I made a new directory src/textview to hold mod.rs, trait.rs and appkit.rs. I've stolen most of the code as a mixture of src/view and src/label, and changed everything to say TextView. Everything seems to compile correctly, except that the window that appears doesn't have a textview.

I've tried putting print statements in the call backs and my TextViewDelegate and it seems to be registered properly. The call backs in the TextView itself for editing don't fire. I don't know where to go from here. I think part of the issue is I don't understand how we are actually interfacing with Objective-C. I'm using msg_send!() macros a lot in my appkit.rs but I don't know how to test to see if any of them are working.

If you're willing, I'll submit a pull request so maybe you or other people can look at what I've done wrong. If not, I'll close this issue and try a more familiar front end for my rust text editor. Thank you for your time!

from cacao.

ryanmcgrath avatar ryanmcgrath commented on July 20, 2024

Feel free to open a PR or link a sample repo, I'm happy to take a look. :)

from cacao.

jasoneveleth avatar jasoneveleth commented on July 20, 2024

Checkout the textview branch of my fork.

from cacao.

ryanmcgrath avatar ryanmcgrath commented on July 20, 2024

I'll have to look more over the weekend, but at a glance, you're calling new to create your NSTextView - as far as I know that's not going to allocate text storage behind the scenes. To get the simplest version working I would probably just call it like:

(pseudo-code, you can dig around for the imports)

let zero: CGRect = Rect::zero().into();
let alloc: id = msg_send![class, alloc];
msg_send![alloc, initWithFrame:zero]

If memory serves correct you may also have to fiddle with AutoLayout for it - it also looks like you're pinning content to content, you probably want to pin input to content anchors instead.

from cacao.

jasoneveleth avatar jasoneveleth commented on July 20, 2024

You were right, my auto layout was messed up. I fixed it and tested it with a normal view and now it should work properly.

I also realized I was calling the wrong functions for registering the class. Or maybe they were correct and just poorly named.

My plan is to try to closely compare with the view module until I can see the textview showing up with a background color.

from cacao.

ryanmcgrath avatar ryanmcgrath commented on July 20, 2024

Closing this for now, but feel free to reopen if you end up with more questions~

from cacao.

WeetHet avatar WeetHet commented on July 20, 2024

I also really need this, so can we consider reopening?

from cacao.

ryanmcgrath avatar ryanmcgrath commented on July 20, 2024

It can be open, sure - but for this particular thing I'm mostly looking for people who will issue a PR. I don't have the time for this particular piece myself. I may get to it in the future if it crosses over with something I'm building though.

from cacao.

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.