Comments (9)
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.
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.
Feel free to open a PR or link a sample repo, I'm happy to take a look. :)
from cacao.
Checkout the textview
branch of my fork.
from cacao.
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.
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.
Closing this for now, but feel free to reopen if you end up with more questions~
from cacao.
I also really need this, so can we consider reopening?
from cacao.
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)
- NSMutableArray HOT 1
- Can't seem to make Button fire when clicked HOT 4
- Improved documentation for ListView HOT 16
- tvOS example HOT 5
- TextField not on edit mode at window opening HOT 2
- Method to access the layout anchors of a view HOT 3
- Get screen dimensions for positioning below toolbar
- Window closes on blocking operations HOT 2
- SplitViewController doesn't implement Layout (or super-trait ObjcAccess) - example code? HOT 4
- Setting window level HOT 6
- _action.request.absolute_url() exit with segmentation fault error HOT 8
- MenuItem's objc pointer is private HOT 2
- Capability to resize Images HOT 3
- missing CALayer.contents -> Any? HOT 3
- Async, Background, and Local Dispatchers support HOT 4
- Class with name RSTApplication could not be found HOT 3
- [UISceneConfiguration isEqualToString:]: unrecognized selector error with 0.4.0-beta1 HOT 4
- ViewAnimatorProxy?
- Mixing runtimes HOT 4
- Story for unowned pointers in collections HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cacao.