Closed MerlinDE closed 3 years ago
This is probably perfect, haha - I needed these myself but hadn’t gotten around to adding them.
I need to push my (...big, but shouldn’t be breaking for you) changes to get things in sync here. Maybe my Sunday night project.
On Sun, Mar 14, 2021 at 09:55, Alexander Czernay @.***> wrote:
Added
- text_should_begin_editing()
- text_did_begin_editing()
- text_did_change()
- text_should_end_editing()
- text_did_end_editing() event handlers.
For now these only take the value from the TextField and hand it over as a String.
@.***(https://github.com/ryanmcgrath) Hope this doesn't create any races/incompatibilities with your central notification center implementation.
You can view, comment on, or merge this pull request online at:
https://github.com/ryanmcgrath/cacao/pull/5
Commit Summary
- Standard macOS event handlers for TextField
File Changes
- M src/input/macos.rs (87)
- M src/input/mod.rs (50)
- M src/input/traits.rs (33)
Patch Links:
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Hmmm, so looking at this, one thing I think we should consider changing - rather than doing to_string()
in the extern fn, call the trait method with the &str
reference and let the implementor allocate if they need or want to. I believe with the current approach, a stock input label with delegate would allocate a string on every event.
If we can be sure that the &str
remains stable in memory it makes perfect sense. I'm not experienced enough with Cocoa to judge on this — especially within a callback that might run in a separate thread AFAIU. Happy to try, though. :)
I'd think it's stable for that call point, but the remark about it potentially running in a separate thread makes me pause, haha...
Is there some documentation (I know I'm asking for Cocoa-specific docs, so the answer may be a resounding "nope"...) that indicates this can happen? I've never experienced it, but very open to being misinformed here.
(I can dig further on this and see what I can come up with)
I‘m afraid I misinterpreted some of your code in regards to having it running in a separate thread. Let’s just go with the &str
.
Going ahead and merging this, will alter the &str
bit in my next push. Really appreciate it!
Added
For now these only take the value from the TextField and hand it over as a String.
@ryanmcgrath Hope this doesn't create any races/incompatibilities with your central notification center implementation.